Building Anime RNG Roblox Game
Markdown--- name: building-anime-rng-roblox-game description: Generates a complete Anime Sword & Magic RNG game prototype combining a playable Three.js/React web demo with exportable Roblox Studio Luau scripts. Use when designing gacha/RNG simulator games, building anime-style low-poly 3D web prototypes, or generating Roblox RNG game systems (rarity tables, server-side roll logic, cutscene VFX, procedural map generation). ---
Produce a two-tab web application:
- Tab 1 — Playable 3D Prototype: React + Three.js + Tailwind, rendering a low-poly anime floating island with a working roll/gacha loop.
- Tab 2 — Luau Code Exporter: copy-button panel with 4 production-ready Roblox scripts.
Build the data model first — both tabs consume it: the web prototype for live rolling/VFX, the exporter for generating RarityConfig.lua. Never author the rarity table twice.
TypeScript// Single source of truth — drive both tabs from this array interface AuraTier { id: number; name: string; nameEn: string; oddsOneIn: number; // e.g. 1500 = "1 in 1500" class: "Low" | "Heroic" | "Mythic" | "Singularity"; colorHex: string; secondaryHex: string; goldPerSec: number; luckBonusPct?: number; goldBonusPct?: number; cutsceneTier: 0 | 1 | 2 | 3; // derived, see breakpoints below — never set by hand vfxDescription: string; } const deriveCutsceneTier = (oddsOneIn: number): 0 | 1 | 2 | 3 => oddsOneIn < 1500 ? 0 : oddsOneIn < 50_000 ? 1 : oddsOneIn < 10_000_000 ? 2 : 3;
Progress:
- [ ] 1. Define the 12-tier rarity table; derive cutsceneTier via the breakpoint function, never hardcode it
- [ ] 2. Build Three.js scene: floating island, sakura trees, altar, character placeholder, particle system
- [ ] 3. Implement core loop: Roll button → weighted RNG (integer cumulative weights) → VFX tier dispatch → inventory/gold update
- [ ] 4. Implement Mana Awakening bar: spawnable crystals, click-to-charge, Overdrive state (2x speed, 3x luck, timer)
- [ ] 5. Implement Guild Shop (luck/speed/gold upgrades) and Alchemist Forge (duplicate → potion crafting)
- [ ] 6. Implement weather events: Golden Harvest, Blood Moon (sky color lerp, demonic variant unlock)
- [ ] 7. Build cutscene VFX system with 3 escalating, nested tiers (flash → impact frame + shake → global event)
- [ ] 8. Build Tab 2 exporter UI: one-click copy for each of 4 Luau files, templated from the same TS array
- [ ] 9. Write RarityConfig.lua mirroring the web rarity table exactly (same odds, colors, bonuses)
- [ ] 10. Write ServerRNGManager.server.lua: weighted roll, luck multiplier stacking, leaderstats, DataStore
- [ ] 11. Write CutsceneClient.client.lua: TweenService camera work, Lighting effect flashes, restore-after-cutscene
- [ ] 12. Write GenerateMedievalMap.lua: idempotent build — altar, rune circle, bridges, islands, sakura, crystals
- [ ] 13. Polish UI chrome: gold-bordered RPG panels, button hover/press animations, rarity-colored glows
- [ ] 14. QA pass: verify weight sums, breakpoint correctness, Tab1/Tab2 parity, no console/runtime errors
- Store
weight = 1 / oddsOneInscaled to a common integer denominator (e.g. total pool = 500,000,000, matching the rarest tier) for cumulative-weight RNG. Never compare raw floats — precision errors corrupt odds at the 1-in-hundreds-of-millions scale. cutsceneTieris always derived fromoddsOneInvia fixed breakpoints (<1500→0,1500–49999→1,50000–9999999→2,≥10000000→3). VFX intensity reads from this derived field only — never branch per-aura-name.- Every tier needs: a unique hex color pair (primary glow + secondary particle), a one-line VFX description, and a
goldPerSecroughly 4-5x the previous tier. Keep the curve exponential, not linear — this is what makes high rolls feel earned. - When inserting/removing a tier, recompute the weight denominator and re-sort by
oddsOneInbefore regenerating Luau output — a stale sort order breaks cumulative-weight lookup.
- Low-poly primitives only (icosahedrons, cones, flattened cylinders) with
MeshToonMaterialor flat-shadedMeshStandardMaterial. No PBR-realistic materials — it breaks the anime aesthetic immediately. - Particles (sakura petals, mana motes, impact sparks): use
THREE.Pointswith sprite billboards or a custom shader, not thousands of individual meshes — meshes will tank frame rate past ~500 instances. - Sky: a lerp-able uniform/gradient shader so weather events and Tier 3 cutscenes can animate it over 1-2s (
gsapor manualrequestAnimationFramelerp). - Camera shake: offset from a saved origin with decaying sine noise over a fixed duration (~0.4s for Tier 2); always restore to origin afterward — never mutate the base transform permanently.
- Levitation pose (rarity ≥1500): sine-bob Y tween + trail particles spawned along the movement vector.
| Tier | Odds range | Beats |
|---|---|---|
| 1 | 1:1,500 – 1:49,999 | screen dim → 8-point star flash in aura color → 360° camera orbit (~1.5s) → reveal |
| 2 | 1:50,000 – 1:9,999,999 | mute SFX bus → B&W impact-frame flash (2-3 frames) → vertical light beam from sky → ground-crack rune decal → sword-slash name reveal → high-amplitude fast-decay camera shake |
| 3 | ≥1:10,000,000 | global sky recolor to aura theme (all clients) → map-wide holographic aura symbol → expanding shockwave ring across terrain → 3-4s extended camera hold before reveal |
Rule: higher tiers must contain all lower-tier beats (Tier 3 includes the Tier 2 impact frame, etc.) — this is what sells escalating rarity visually. Never skip beats to save implementation time.
- RarityConfig.lua — pure data module,
return { Auras = {...} }. No logic, no RNG, no Instance creation. Must carryWeight,Color3,GoldPerSec,LuckBonus,CutsceneTierper entry, templated directly from the TS array. - ServerRNGManager.server.lua — owns all RNG via a single
Random.new()instance (never reseed per-call), readsRarityConfig, applies the player's full luck stack (base + upgrades + potions + awakening), fires aRemoteEventto the roller's client only, accruesleaderstats.GoldviaHeartbeat/task.wait()loop, autosaves throughDataStoreService:UpdateAsyncwrapped inpcallwith retry/backoff. - CutsceneClient.client.lua — listens to the RemoteEvent, branches purely on
CutsceneTier(never aura name), drivesTweenServicefor camera +Lightingeffects (ColorCorrectionEffect/BloomEffect), and always tweens Lighting back to defaults when the cutscene ends. - GenerateMedievalMap.lua — idempotent:
if workspace:FindFirstChild("ValoriaMap") then it:Destroy() endbefore building. Parents everything under oneFoldernamedValoriaMap, sub-foldered by category (islands/bridges/trees/crystals), batch-sets properties, anchors all parts.
Example 1:
Input: "Add a new rarity tier between Lunar Eclipse Mage and Abyssal Monarch"
Output: Insert into the shared array with oddsOneIn between 50,000 and 250,000 (e.g. 120,000). Re-sort the array, recompute the integer weight denominator, let cutsceneTier derive automatically (→2, since it falls in the 50k-9.99M range). Pick a color pair distinct from both neighbors. Regenerate RarityConfig.lua from the updated array — no manual edits to the Luau file, no other systems change.
Example 2:
Input: "Player clicks Roll during Overdrive mode"
Output: Server multiplies effective luck by 3x and halves roll cooldown, reading a single IsAwakened boolean. Client overlays an Overdrive fire-particle effect underneath whatever cutscene tier the roll result triggers — the two systems never duplicate multiplier logic.
Example 3:
Input: "QA found Tier 3 cutscene leaves the sky permanently recolored"
Output: Bug in CutsceneClient.client.lua — the sky-recolor tween has no corresponding tween-back on cutscene end. Fix: capture original Lighting property values before the cutscene starts, and schedule a reverse tween (same duration as the forward one) once the reveal UI beat completes. Apply the identical fix to the Tab 1 Three.js sky lerp if it shares the bug.
- Keep the rarity table the single source of truth — template
RarityConfig.luadirectly from the TS array so web and Luau can never drift. - Use integer cumulative-weight RNG, never nested float probability checks, for correctness at 1:500,000,000 scale.
- Derive VFX tier from odds breakpoints, not aura identity — keeps the cutscene system reusable as the aura list grows.
- Make map generation idempotent and safely re-runnable.
- All monetary/luck math happens server-side; the Luau client only renders what the server pushes via RemoteEvent.
- Always save and restore Lighting/camera state around tweened cutscene effects.
- Hardcoding 12 per-aura VFX branches instead of deriving tier from odds breakpoints.
- Using
math.random()float-chain checks for rare tiers — precision errors skew 1-in-500-million odds. - Letting the client compute or trust its own roll result — always authoritative server RNG + RemoteEvent push.
- Forgetting to restore
Lightingproperties and camera CFrame after cutscenes, breaking subsequent gameplay. - Using photorealistic materials/lighting in Three.js, contradicting the low-poly anime direction.
- Regenerating the map script without destroying the previous
ValoriaMapfolder first, causing duplicate geometry. - Editing
RarityConfig.luaby hand after a web-side table change — always regenerate from the shared array.