Roblox leaderboard script: leaderstats you can copy and paste
Short answer
Create a Folder named exactly "leaderstats" inside each player when they join, and put IntValue or NumberValue objects in it. Roblox shows every value in that folder on the in-game player list. Change the values only from server scripts.
- Insert a Script (not a LocalScript) in ServerScriptService and paste the code.
- Press Play: Coins and Level appear on the player list at the top right.
- To make them save, load and save the values with the DataStore script linked below.
Copy-paste code
ServerScriptService/Leaderstats.server.lua
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local stats = Instance.new("Folder")
stats.Name = "leaderstats" -- must be exactly this name, all lowercase
stats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = stats
local level = Instance.new("IntValue")
level.Name = "Level"
level.Value = 1
level.Parent = stats
end)
-- From any other server script:
-- player.leaderstats.Coins.Value += 10Good to know
Changing leaderstats from a LocalScript only changes it on that player's screen; other players and the server never see it. Use a RemoteEvent to ask the server, and let the server decide.
The first value in the folder decides the sort order of the player list.
Studwright: Roblox systems that never lose saves
from $12Studwright is 16 tested Luau modules: session-locked SaveData, Receipts (developer products granted once), Codes, DailyRewards, PlaytimeRewards, Leaderboard, LootTable, Inventory, Currency, RemoteGuard and more, as a drag-in .rbxmx with the tests.
Secure checkout · 14-day fix-or-refund if it doesn't work as described (terms)Questions
Why doesn't my leaderboard show?
The folder must be named leaderstats (lowercase) and created by a server Script inside the Player object.
Can I show text instead of numbers?
Yes, use a StringValue; it shows as text but the list then can't sort numerically by it.
How do I make a global leaderboard?
Use an OrderedDataStore; see the global leaderboard guide below.
Free: the Roblox Starter Kit
7 free Luau modules (damage, pets, shop formatting, admin audit log, tycoon guards and more) plus 3 free calculators, then 5 short emails with the scripting fixes we see go wrong most often.