How do I create a leaderstat like a leaderboard?
A little Help with making leaderstats?
2 answers
To create leaderboards, you must have a certain structure within each player. For the leaderboard to show, every client must have a model inside their player called leaderstats, in which values may be added to be shown on the leaderboard.
You can make these leaderstats models using PlayerAdded in a script. For example, if you wanted to make a leaderstat called Money, you could do something like this in a script:
local statName = "Money"
game.Players.PlayerAdded:Connect(function(plr)
local stats = Instance.new("Model")
stats.Name = "leaderstats"
local money = Instance.new("NumberValue")
money.Name = statName
money.Parent = stats
stats.Parent = plr
end)
Then, whenever you wanted to add to the leaderstat, you could do something like this:
player.leaderstats.Money.Value = player.leaderstats.Money.Value + 1
(keeping in mind that you have to define player)
For more information on leaderboards, you can look here.
1 comment
Ok thanks
Well, first you'll need a server script which means a normal script in the server. Then, you'll have to create any value with the name of "leaderstats" and place its parent into the Player.
It's best if you do a PlayerAdded connection to get the player and give them the leaderboard when joined.
Once you've done that, create other values inside the leaderstats value. So, meaning it should be like this game > Players > PlayerName > leaderstats > YourValue.
But.. you can also look at the official roblox wiki that has the leaderboards page.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
http://wiki.roblox.com/index.php?title=Leaderboards
https://scriptinghelpers.org/help/how-post-good-questions-answers