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

What is the best way to make a custom leaderboard?

Asked by 10 years ago

I am curious what is the best way to make a custom leaderboard, like a GUI leaderboard. Are there any methods I can use to get & list players and their stats? What might be the best layout? I am curious to know what might be the best way to do this.

2 answers

Log in to vote
3
Answered by 10 years ago

Basically, all you need to know is the players in the game (which can be resolved using PlayerAdded/PlayerRemoved/GetPlayers), and list them in a UI. You can also get special statistics and display those in the UI, by creating and/or viewing them using Lua. Say you want to track kills; every time the 'kills' value is changed, update the player list accordingly.

Ad
Log in to vote
0
Answered by
drahsid5 250 Moderation Voter
10 years ago

It is actually quite simple; First you want to create the values, so in a local script put something like this:

repeat wait() until game.Players.LocalPlayer
local Plr = game.Players.LocalPlayer
if Plr.Leaderboard  then--You might need to use find first child, I forgot
print "Stats already created"
else --Might need to be elseif not Plr.Leaderboard
local Values = {
"Value1"
,"Value2"
}
local Stats = Instance.new("Configuration",Plr) --Configurations are more fancy than models
Stats.Name = "Leaderboard"
for i=1, #Values do

local NewStat = Instance.new([ValueType], Stats) --"[ValueType]" is the sort-of value you want, if you want to make each variable have a different value then you make a table inside of a table to decide what value is with what variable.
NewStat.Name = Values[i]

end

Then you'd make a GUI to display the values, like

game.Players.LocalPlayer.Leaderboard.Value1.Changed:connect(function()
script.Parent.Text = game.Players.LocalPlayer.Leaderboard.Value1.Value
end)

It is pretty simple. If you need any help, ask.

0
Note: I wouldn't do Instance.new("Configuration",Plr) as setting the parent in the Instance makes it really laggy in the long run if you're making something decently big. Just define the parent after with Stats.Parent = Plr after Stats.Name = "Leaderboard".Also you could always store values in a folder in Server Storage called PlayerInfo. Give each player a folder which you delete when they leave. CodeOnRBLX 1 — 6y

Answer this question