Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I add leaderboards?

Asked by 3 years ago

hello, I have just started coding on roblox and i want to make a simple clicker/simulator game. why does this code not work for a leaderboard?

game.Players.PlayersAdded:Connect(function(player) local stats = Instance.new("Folder") stats.Name = "leaderstats" stats.Parent = player

local power = Instance.new("IntValue")
power.Name = "Power"
power.Value = 0
power.Parent = stats

local cash = Instance.new("IntValue")
cash.Name = "Power"
cash.Value = 0
cash.Parent = stats

end)

0
It should be a ServerScript inside of ServerScriptService killerbrenden 1537 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago
game.Players.PlayerAdded:Connect(function(Player)

local Leaderstats = Instance.new("IntValue")
Leaderstats.Name = "leaderstats"
Leaderstats.Parent = Player

local Power = Instance.new("IntValue")
Power.Name = "Power"
Power.Parent = Leaderstats
Power.Value = 0

end)

-- Note: It should be a server script, not a local script. There is no reason why this wouldn't work tho. If you want it to save you'll need to add a dataStore.

For more help refer to this page. https://developer.roblox.com/en-us/articles/Leaderboards

Ad

Answer this question