{"slug":"roblox-simulator-economy","title":"roblox-simulator-economy","summary":"Design, balance, and implement the economy of a Roblox simulator, tycoon, clicker, or idle game in Luau: upgrade cost curves, buy max, income per second, rebirth/prestige requirements and multipliers, offline earnings, big-number display (1.5K, 3.4M, 2.0Qa), server-authoritative ","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-09T16:58:26.025751Z","repo":{"url":"https://github.com/gamedev-skills/awesome-gamedev-agent-skills","stars":7979,"forks":782,"license":"Apache-2.0","updatedAt":"2026-11-09T16:00:44Z"},"bodyHtml":"<hr>\n<h2>name: roblox-simulator-economy\ndescription: &gt;\nDesign, balance, and implement the economy of a Roblox simulator, tycoon, clicker, or idle game\nin Luau: upgrade cost curves, buy max, income per second, rebirth/prestige requirements and\nmultipliers, offline earnings, big-number display (1.5K, 3.4M, 2.0Qa), server-authoritative\npurchases, repairing tampered or old save data, and odds disclosure for paid random items such\nas eggs, crates, and spins. Includes a Lune pacing calculator. Use when choosing or checking\nbaseCost/costGrowth/rebirth numbers, writing upgrade/currency/rebirth/offline code, or when\nprogress stalls, a rebirth takes far longer than the last, numbers display as 1000K, offline\nearnings pay too much, or players gain currency they did not earn.</h2>\n<h1>Roblox simulator economy</h1>\n<p>Choose the economy's numbers with a pacing table before writing gameplay code, then implement them\nso the server owns every amount. Code targets Luau on Roblox's rolling platform APIs; the bundled\nscripts are pure Luau and were run with <strong>Lune 0.11.0</strong>, outside Studio.</p>\n<h2>When to use</h2>\n<ul>\n<li>Picking or reviewing <code>baseCost</code>, <code>costGrowth</code>, rebirth requirement and multiplier, or offline\ncap and efficiency values for a simulator, tycoon, clicker, or idle game.</li>\n<li>Writing upgrade, buy-max, currency, rebirth, or offline-earnings code in Luau.</li>\n<li>Displaying large numbers, or values above about <code>1e15</code> that lose precision.</li>\n<li>Adding eggs, crates, or spins bought with Robux, or with currency that can be bought with Robux.</li>\n</ul>\n<p><strong>When not to use:</strong> DataStore reads, writes, session locking and retries → <code>roblox-datastores</code>.\nRemote protocol design and rate limiting in depth → <code>roblox-networking</code>. Shop and HUD layout →\n<code>roblox-ui</code> + <code>game-ui-ux</code>. A wave-defense economy → <code>tower-defense</code>. Engine-neutral save format\nquestions → <code>save-systems</code>.</p>\n<h2>Workflow</h2>\n<ol>\n<li><strong>Inspect.</strong> Find where currency, upgrade, and rebirth values live now and which scripts change\nthem. List every RemoteEvent that touches currency and what each one sends.</li>\n<li><strong>Write the numbers as one config table</strong>: base income; each upgrade's <code>baseCost</code>,\n<code>costGrowth</code>, effect, and <code>maxLevel</code>; rebirth <code>baseRequirement</code>, <code>requirementGrowth</code>,\n<code>multiplierPerRebirth</code>; offline <code>maxHours</code>, <code>efficiency</code>. Server and client both read it.</li>\n<li><strong>Run the pacing calculator</strong> from the skill directory (paths are relative to it):\n<code>lune run scripts/balance.luau --print-defaults &gt; economy.json</code>, edit the file, then\n<code>lune run scripts/balance.luau economy.json</code>. Read the <code>wait</code> and <code>vs prev</code> columns and tune\nuntil they match the targets below. <code>--help</code> lists every field and its allowed range; a\nmissing file, invalid JSON, or out-of-range field prints an error and exits 1.</li>\n<li><strong>Implement on the server</strong> with the patterns below and\n<a href=\"references/server-patterns.md\">references/server-patterns.md</a>. Copy\n<code>scripts/economy_math.luau</code> unchanged into a ModuleScript so the maths you tested is the maths\nthat runs.</li>\n<li><strong>Verify.</strong> <code>lune run scripts/test_economy_math.luau</code> (exits 1 on failure) for the maths; a\nStudio playtest with Server &amp; Clients for purchases, rebirth, leaving and rejoining, and\ninvalid remote arguments.</li>\n</ol>\n<h2>Formulas</h2>\n<table>\n<thead>\n<tr>\n<th>Quantity</th>\n<th>Formula</th>\n<th>Notes</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Price of the next level</td>\n<td><code>floor(baseCost * costGrowth ^ owned)</code></td>\n<td>1.07-1.15 for upgrades bought many times; 1.5-3 for rare large ones</td>\n</tr>\n<tr>\n<td>Cost from level a to b</td>\n<td><code>baseCost * g^a * (g^(b-a) - 1) / (g - 1)</code></td>\n<td>Players pay the floored per-level sum, slightly less</td>\n</tr>\n<tr>\n<td>Buy max</td>\n<td>walk real prices until the next exceeds the balance or <code>maxLevel</code></td>\n<td>Safer than the log formula with floored prices</td>\n</tr>\n<tr>\n<td>Rebirth requirement k</td>\n<td><code>baseRequirement * requirementGrowth ^ k</code></td>\n<td></td>\n</tr>\n<tr>\n<td>Rebirth multiplier</td>\n<td><code>1 + k * multiplierPerRebirth</code></td>\n<td>Additive grows slowly; multiplicative (<code>q ^ k</code>) grows exponentially</td>\n</tr>\n<tr>\n<td>Offline income</td>\n<td><code>floor(min(away, maxHours * 3600) * rate * efficiency)</code></td>\n<td>Away time of 0 or less (clock went back) pays 0</td>\n</tr>\n</tbody>\n</table>\n<p>Derivations, the rebirth wait-ratio formula, and a worked example:\n<a href=\"references/formulas.md\">references/formulas.md</a>.</p>\n<h2>Pacing targets (starting points, not rules)</h2>\n<ul>\n<li><strong>Early upgrades take seconds.</strong> In the default config the first 10 levels take 3-10 s each.</li>\n<li><strong>Each rebirth should take only a little longer than the last</strong>, for example x1.2-x1.5. The\ncalculator's <code>vs prev</code> column is that ratio. With an additive multiplier it approaches\n<code>requirementGrowth</code> over time, so <code>requirementGrowth = 3</code> gives x2.0 rising to x2.7 and rebirth 8\ntakes 137 days at the default income. <code>requirementGrowth = 1.8</code> gives x1.2 rising to x1.6.</li>\n<li><strong>Offline earns less than online.</strong> An efficiency of 0.25-0.5 and an 8-12 hour cap keep playing\nworth more than idling without zeroing out players who log off.</li>\n</ul>\n<h2>Server-owned purchases</h2>\n<p>A RemoteEvent carries what the player wants (\"buy upgrade <code>Income</code>\"), never an amount or a price.\nThe server looks up the price, checks the balance, spends, and grants without yielding in between.</p>\n<pre><code>-- ServerScriptService/Economy.server.luau (excerpt; full version in references/server-patterns.md)\nlocal ReplicatedStorage = game:GetService(\"ReplicatedStorage\")\nlocal EconomyMath = require(ReplicatedStorage.Shared.EconomyMath)\nlocal Config = require(ReplicatedStorage.Shared.EconomyConfig)\n\nReplicatedStorage.Remotes.BuyUpgrade.OnServerEvent:Connect(function(player: Player, upgradeId: unknown)\n\tlocal session = sessions[player]\n\tif not session or type(upgradeId) ~= \"string\" then return end\n\tlocal upgrade = Config.upgrades[upgradeId]\n\tif not upgrade then return end -- unknown id\n\tlocal owned = session.levels[upgradeId] or 0\n\tif owned &gt;= upgrade.maxLevel then return end\n\tlocal price = EconomyMath.levelCost(upgrade.baseCost, upgrade.costGrowth, owned)\n\tif EconomyMath.trySpend(session.wallet, { [upgrade.currency] = price }) then\n\t\tsession.levels[upgradeId] = owned + 1\n\tend\nend)\n</code></pre>\n<ul>\n<li><code>trySpend</code> checks every currency in a multi-currency cost before subtracting any, and rejects\nnegative or non-finite costs.</li>\n<li><strong>Rebirth on the server</strong>: compare the server's balance with the requirement, then reset wallet\nand levels and increment the count. Never accept \"I rebirthed\" or a balance from the client.</li>\n<li>Rate-limit each remote per player with a token bucket (<code>roblox-networking</code>).</li>\n</ul>\n<h2>Save data and offline time</h2>\n<ul>\n<li><strong>Repair on load; never error.</strong> Use <code>sanitizeAmount</code> (non-numbers, NaN, infinity and negatives\nbecome 0; fractions are floored) and <code>sanitizeLevel</code> (also clamps to the current <code>maxLevel</code>).\nDrop unknown upgrade ids and return a list of what was repaired, so old versions and edited data\nload cleanly.</li>\n<li><strong>Never save NaN or infinity.</strong> A division by zero that reaches the wallet should be caught by\nthe same sanitizers before saving.</li>\n<li><strong>Offline time comes from the server clock only</strong>: save <code>os.time()</code> on the server when the\nplayer leaves; on join, <code>away = os.time() - lastSeen</code>. A missing or future <code>lastSeen</code> counts as\nnow, which pays nothing.</li>\n<li><strong>Precision:</strong> Luau numbers are doubles, exact for integers up to <code>2^53</code> (about <code>9e15</code>). If\nbalances can pass about <code>1e15</code>, store a mantissa/exponent pair or a base-10 logarithm instead.</li>\n</ul>\n<h2>Big-number display</h2>\n<p><code>EconomyMath.formatNumber(value, decimals?)</code> uses the suffixes K, M, B, T, Qa, Qi, Sx, Sp, Oc, No,\nDc, Ud, Dd, Td, Qad, Qid, Sxd, Spd, Ocd, Nod, Vg (<code>1e63</code>), then scientific notation.</p>\n<ul>\n<li><strong>The rollover bug:</strong> <code>999950 / 1000 = 999.95</code>, which rounds to <code>\"1000.0K\"</code>. Round first; if the\nrounded value reaches 1000, move to the next suffix (<code>\"1.0M\"</code>). The tests cover this case.</li>\n<li>Format on the client for display only; never parse a formatted string back into a number.</li>\n</ul>\n<h2>Paid random items (eggs, crates, spins)</h2>\n<p>Roblox's <a href=\"https://create.roblox.com/docs/production/monetization/paid-random-items\">paid random items guidelines</a>\napply when a random item is bought with Robux, directly or through in-game currency bought with\nRobux. Per that page:</p>\n<ul>\n<li>Show every possible outcome and its actual numerical odds, as percentages that sum to exactly\n100%, before purchase (long decimals may be rounded, with a note that the shown total may not be\nexactly 100%).</li>\n<li>Probability modifiers such as luck boosts and pity systems are covered: explain their effect\nnumerically before purchase, and update the shown odds live while a boost is active.</li>\n<li>If the full list does not fit, open it from a control labelled \"Info\" or \"Details\" that is\nvisible before purchase; an \"(i)\" icon without a word is not enough.</li>\n<li><code>PolicyService:GetPolicyInfoForPlayerAsync()</code> returns <code>ArePaidRandomItemsRestricted</code>; for those\nplayers, apply one of the treatments the page lists.</li>\n</ul>\n<p>Build the odds panel with <code>EconomyMath.oddsPercent(outcomes)</code> and roll on the server with\n<code>EconomyMath.pickWeighted(outcomes, rng:NextNumber())</code> from the <strong>same</strong> list (after applying any\nboost), so shown and actual odds cannot drift.</p>\n<h2>Pitfalls</h2>\n<ul>\n<li><strong>Rebirth 6 takes weeks</strong> → <code>requirementGrowth</code> far above the multiplier's growth; read the\n<code>vs prev</code> column and lower <code>requirementGrowth</code> or switch to a multiplicative multiplier.</li>\n<li><strong>Prices outrun income after ~20 levels</strong> → <code>costGrowth</code> of 1.5+ on an upgrade meant\nto be bought 50 times (level 50 costs about 637 million times level 0); use 1.07-1.15.</li>\n<li><strong>Late game breaks after a few rebirths</strong> → multiplicative multiplier (<code>1.5 ^ k</code>) without a\nmatching requirement curve; keep <code>requirementGrowth / q</code> near the ratio you want.</li>\n<li><strong>Players gain currency they did not earn</strong> → a remote accepts an amount or price, or the check\nhappens only on the client; send ids, price on the server.</li>\n<li><strong>Two purchases pass one balance check</strong> → the handler yields between check and spend; spend\nbefore any <code>task.wait</code>, DataStore call, or other yield.</li>\n<li><strong>Buy max freezes the server</strong> → uncapped loop or a price of 0; pass <code>maxLevel</code>, keep\n<code>baseCost &gt;= 1</code> (<code>maxAffordable</code> errors instead of looping forever).</li>\n<li><strong>Offline pays days of income</strong> → client timestamp, no cap, or a corrupted <code>lastSeen</code>; use the\nserver clock, cap, and treat future times as now.</li>\n<li><strong>HUD shows \"1000.0K\"</strong> → <code>math.floor(x * 10) / 10</code> before choosing the suffix; use\n<code>formatNumber</code>.</li>\n<li><strong>A save fails or loads as garbage</strong> → NaN or infinity reached the wallet; sanitize before save\nand on load.</li>\n</ul>\n<h2>Resources</h2>\n<ul>\n<li><code>scripts/balance.luau</code> — pacing calculator: per-level price, total, income and wait; per-rebirth\nrequirement, multiplier, wait and ratio; offline maximum. Run with <code>--help</code> first.</li>\n<li><code>scripts/economy_math.luau</code> — the formulas, <code>trySpend</code>, sanitizers, odds and <code>formatNumber</code> as\npure Luau; runs in Lune and in a Roblox ModuleScript.</li>\n<li><code>scripts/test_economy_math.luau</code> — tests for every function (<code>lune run</code>, exits 1 on failure).</li>\n<li><a href=\"references/formulas.md\">references/formulas.md</a> — derivations, rebirth ratio, worked example.</li>\n<li><a href=\"references/server-patterns.md\">references/server-patterns.md</a> — config layout, income tick,\nbuy max, rebirth, load repair with offline income, and paid random item rolls.</li>\n</ul>\n<h2>Related skills</h2>\n<ul>\n<li><code>roblox-luau</code> — services, ModuleScripts, and the client/server split.</li>\n<li><code>roblox-networking</code> — remote validation and token-bucket rate limits.</li>\n<li><code>roblox-datastores</code> — loading and saving the session this skill repairs.</li>\n<li><code>roblox-ui</code> — shop, upgrade, and odds panels.</li>\n<li><code>roblox-studio-workflow</code> — Server &amp; Clients playtests.</li>\n</ul>\n<h2>Primary references</h2>\n<ul>\n<li><code>https://create.roblox.com/docs/production/monetization/paid-random-items</code></li>\n<li><code>https://create.roblox.com/docs/scripting/events/remote</code></li>\n<li><code>https://create.roblox.com/docs/scripting/security/client-server-boundary</code></li>\n<li><code>https://create.roblox.com/docs/reference/engine/classes/PolicyService</code></li>\n<li><code>https://create.roblox.com/docs/reference/engine/datatypes/Random</code></li>\n<li><code>https://lune-org.github.io/docs</code></li>\n</ul>\n","files":[{"path":"agents/openai.yaml","sizeBytes":229,"isText":true},{"path":"references/formulas.md","sizeBytes":4306,"isText":true},{"path":"references/server-patterns.md","sizeBytes":9187,"isText":true},{"path":"scripts/balance.luau","sizeBytes":7249,"isText":false},{"path":"scripts/economy_math.luau","sizeBytes":7267,"isText":false},{"path":"scripts/test_economy_math.luau","sizeBytes":8007,"isText":false},{"path":"SKILL.md","sizeBytes":11842,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-09T17:01:14.708154Z","sha256":"AF5413EA109621C48E45AE3CC17CBF257BA3FD20238B72F0FF6EF29FC808BA65","sizeBytes":19268},"review":null,"source":{"repositoryUrl":"https://github.com/gamedev-skills/awesome-gamedev-agent-skills","path":"skills/other-engines/roblox-simulator-economy","license":"Apache-2.0","commit":"4cce500ce1a779b12fdd824be581c7d2ab4e7ba2","subtreeSha":"8FB0A10BAECCB9DC654272ED4430EE954F2AD60EE2102C99496FC5C8252F28F4","lastSyncedAt":"2026-11-09T16:58:15.324999Z"},"reviewedAt":"2026-11-09T17:15:34.094908Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/gamedev-skills/awesome-gamedev-agent-skills/tree/main/skills/other-engines/roblox-simulator-economy"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install gamedev-skills-awesome-gamedev-agent-skills@llmmart"},{"target":"git","command":"git clone https://github.com/gamedev-skills/awesome-gamedev-agent-skills.git"}]}