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

Anyone Have Any Idea Of How To Make A Leaderboard?

Asked by
Fxicity 10
4 years ago

i have save data for my leaderstats already, i was wondering how to implement it into my code. heres my savedata code.

01local DS = game:GetService("DataStoreService"):GetDataStore("SaveMyData")
02game.Players.PlayerAdded:Connect(function(player)
03    wait()
04    local playerkey = "id_"..player.userId
05    local savevalue = player.leaderstats.Points
06    local savevalue2 = player.leaderstats.Prestige
07 
08    local GetSaved = DS:GetAsync(playerkey)
09    if GetSaved then
10        savevalue.Value = GetSaved[1]
11        savevalue2.Value = GetSaved[2]
12    else
13        local NumbersForSaving = {savevalue.Value, savevalue2.Value}
14        DS:GetAsync(playerkey, NumbersForSaving)
15    end
16end)
17 
18game.Players.PlayerRemoving:Connect(function(player)
19    DS:SetAsync("id_"..player.userId, {player.leaderstats.Points.Value, player.leaderstats.Prestige.Value})
20end)

leaderstats

01game.Players.PlayerAdded:Connect(function(player)
02     local leaderstats = Instance.new("Model")
03     leaderstats.Name = "leaderstats"
04     leaderstats.Parent = player
05 
06local money = Instance.new("IntValue")
07     money.Name = "Points"
08     money.Value = 0
09     money.Parent = leaderstats
10local money = Instance.new("IntValue")
11     money.Name = ("Prestige")
12     money.Value = 0
13     money.Parent = leaderstats 
14local money = Instance.new("BoolValue")
15     money.Name = "DoublePass"
16     money.Value = false
17     money.Parent = player
18end)
0
just to expand some more Fxicity 10 — 4y
0
its a top 10 points leaderboard Fxicity 10 — 4y
0
i want it to show the rank the name and the amount of points Fxicity 10 — 4y
0
Here is a nice tutorial. You will need to save values to OrderedDataStore, so it will not work backwards if your game is already live. https://devforum.roblox.com/t/how-to-make-a-simple-global-leaderboard/256754 sleazel 1287 — 4y

Answer this question