RB-004
Roblox leaderstats (coins) script
Adds a Coins number to the player list at the top right of the screen.
- Script type
- Script
- Where it goes
- ServerScriptService
- Category
- Player data and money
For your own game in Roblox Studio. Not for use in other people's games.
The code
-- Leaderstats: creates the player list board with a Coins value.
local STARTING_COINS = 0
local Players = game:GetService("Players")
local function onPlayerAdded(player)
-- The folder MUST be called "leaderstats" for Roblox to show it.
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = STARTING_COINS
coins.Parent = leaderstats
end
Players.PlayerAdded:Connect(onPlayerAdded)
-- Also handle players who joined before this script finished loading.
for _, player in Players:GetPlayers() do
task.spawn(onPlayerAdded, player)
endHow to set it up
- Open ServerScriptService in the Explorer.
- Add a Script and paste the code.
- Play. A box with your name and Coins appears at the top right.
- To see it change while testing, select Coins in the Explorer (under Players > your name > leaderstats) and edit the value.
Change it
- To add more stats, copy the IntValue block and change the name, for example Gems.
- Use a StringValue for text and a NumberValue for decimals.
- Only change leaderstats from a Script. A LocalScript change only shows on that one screen and does nothing for the real game.
- Pair this with the Save data script so coins are kept between visits.
More in Player data and money
- Coin pickup
- Save data with DataStore
- Shop button (RemoteEvent)
- Game pass check
- Developer product handler
More Roblox tools
- Shirt and pants templatesFree Roblox clothing templates to download: hoodies, jerseys, jeans, joggers and more.
- Robux tax calculatorWork out what you receive after the marketplace fee, or what to charge.
- Robux to USD calculatorConvert earned Robux to dollars at a DevEx rate you can edit.
- Shirt and pants template makerColour each panel of the 585×559 clothing template and download it.
- Username generatorGenerate usernames that fit the 3–20 character rule.