Skinstashery
Roblox
Home / Roblox / Studio script library / Leaderstats (coins)
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)
end

How to set it up

  1. Open ServerScriptService in the Explorer.
  2. Add a Script and paste the code.
  3. Play. A box with your name and Coins appears at the top right.
  4. To see it change while testing, select Coins in the Explorer (under Players > your name > leaderstats) and edit the value.

Change it

More in Player data and money

All Roblox scripts

More Roblox tools