FFORGE

Guide · 7 min read · Updated November 2026

Roblox leaderstats script with AI: the folder, the economy module and the board

Leaderstats is a ten-line script, which is why most games get it wrong in a way that costs them later: every shop, button and product edits the IntValue directly, and six months in nobody can say where coins come from. The fix is the same ten lines plus one module that is the only thing allowed to change a stat. This guide shows what to ask an AI for, what it should produce, and how to check it.

The folder, correctly

Players.PlayerAdded:Connect(function(player)
	local stats = Instance.new("Folder"); stats.Name = "leaderstats"
	local coins = Instance.new("IntValue"); coins.Name = "Coins"; coins.Value = data.Coins; coins.Parent = stats
	local rebirths = Instance.new("IntValue"); rebirths.Name = "Rebirths"; rebirths.Value = data.Rebirths; rebirths.Parent = stats
	stats.Parent = player
end)

The economy module: one place coins change

The leaderstat is a display. The truth is in the player's data, and the only code allowed to change it is a server module. Forge's version, from its leaderstats-economy playbook:

With this in place, "where do coins come from" is a search for AddCoins, and every call has a reason string next to it.

The prompt

Set up leaderstats for my game: on PlayerAdded create a Folder named exactly leaderstats
with Coins (IntValue) and Rebirths (IntValue) loaded from the player's data. Create
ServerScriptService.Modules.Economy with AddCoins(player, delta, reason) that validates a
finite integer, never goes below zero, applies multipliers to positive earnings, updates the
data cache and the leaderstat, and fires a CoinsChanged remote; plus CanAfford and Buy.
Nothing else in the game may set Coins directly. Playtest, call AddCoins from the server,
confirm the leaderboard updates, screenshot.

This is the Leaderstats and an economy module prompt. Forge finishes it with a server-side check: read the stat, call AddCoins, print before and after, assert the change. A clean console is not proof; a changed number is.

A global leaderboard

The built-in leaderboard shows the players on this server. A global top 10 needs an OrderedDataStore:

Once a minute keeps a full server inside DataStore request budgets. Prompt page: Global top-10 leaderboard board.

Checks for any AI-written leaderstats script

  1. Search the place for .Value = on Coins. Every hit outside the economy module is a leak.
  2. Search for OnServerEvent handlers that add coins from an argument. The amount must come from server config, never the client.
  3. Confirm multipliers apply to earnings only; a 2x pass that doubles prices is a classic AI mistake.
  4. Confirm the folder is created on the server and only after saved data is loaded (or with a loading state), so a player never sees 0 and then their real balance.

What it costs

Leaderstats plus the economy module is a build step, about 40 to 200 credits ($0.40 to $2) on Sonnet 5.5; the global board is 100 to 350. Ranges and packs are on the pricing page.

Questions

Why does my leaderboard not show my stats?

The Folder must be named exactly leaderstats, lowercase, directly under the Player, and created on the server. Values must be IntValue, NumberValue or StringValue children. A folder named Leaderstats or created in a LocalScript does not show.

How many stats can the leaderboard show?

Four. Keep hidden stats such as click power or luck in the player's data module instead of the folder, and show formatted text (1.2M) with a StringValue if the number gets big.

Can the client change a leaderstat?

It can change its own copy, which nobody else sees and the server ignores. If a change the client makes shows up for everyone, the logic is on the server trusting the client, which is the bug to fix, not a feature.

Does Forge use a different leaderboard?

No. Forge uses the built-in leaderstats folder and adds an economy module around it, from its leaderstats-economy playbook, so existing scripts and tutorials still apply.

Related guides

Let Forge set it up and prove it. Pair your Studio, press Build on the prompt, get the asserted before-and-after back. Trial credits, no card. Build it in Forge →