Really the funny thing about leaderboard stats for a player is that there is no direct file that can display a stat (no generic files of that player). Although the Leaderboard system is a service, it is hidden and cannot be accessed. So if you are trying to create stats for the leaderboard, you must insert an object inside of the player.
A leaderboard/leaderstat is organized in a specific way. In each row for each player, there are two main things that appear. 1) the player that your specifying, and 2) the stat your specifying. It must include the following:
-A model or file that is named "leaderstats" that will stand for a leaderstat/leaderboard
-2) A Value (usually IntValue) to specify any stats that you want to include for each player
Now that we've discussed a little about the structure of the Leaderboard, let's see how we can actually create stats. Like I said, you cannot directly access the Leaderboard service, so we need to create our own (sort of). Let's follow these steps:
First, we need to create a file that specifies there's a LeaderStat within that player (using either a model or a file)
Then we will create a new Vale that will stand for any stats you want to include
EXAMPLE:
player
LeaderStat = Instance.new("Model", player)
LeaderStat.Name = "leaderstats"
Stat = Instance.new("IntValue", LeaderStat)
Now you probably want to organize all of this into your function. There are two ways of creating leaderstats:
- With a local script
or
- with a server - side script
For now, I suggest you focus on server - side scripts, but I'll include both ways/methods anyways!
Server - side:
game.Players.PlayerAdded:connect(function(player)
LeaderStat = Instance.new("Model", player)
LeaderStat.Name = "leaderstats"
Stat = Instance.new("IntValue", LeaderStat)
And the Local one:
player = game.Players.LocalPlayer
LeaderStat = Instance.new("Model", player)
LeaderStat.Name = "leaderstats"
Stat = Instance.new("IntValue", LeaderStat)
If you have any questions, comments, suggstions feel free to post a comment. Otherwise a have a list of links below to everything I explained in this answer:
Roblox Wiki: http://wiki.roblox.com/index.php/Scripting
Leaderboard's: http://wiki.roblox.com/index.php?title=Leaderboard
Model: http://wiki.roblox.com/index.php?title=API:Class/Model
IntValue: http://wiki.roblox.com/index.php?title=API:Class/IntValue
1 comment
For more on Leaderboard's, refer to the wiki -----> http://wiki.roblox.com/index.php?title=Leaderboard