i have save data for my leaderstats already, i was wondering how to implement it into my code. heres my savedata code.
local DS = game:GetService("DataStoreService"):GetDataStore("SaveMyData")
game.Players.PlayerAdded:Connect(function(player)
wait()
local playerkey = "id_"..player.userId
local savevalue = player.leaderstats.Points
local savevalue2 = player.leaderstats.Prestige
local GetSaved = DS:GetAsync(playerkey)
if GetSaved then
savevalue.Value = GetSaved[1]
savevalue2.Value = GetSaved[2]
else
local NumbersForSaving = {savevalue.Value, savevalue2.Value}
DS:GetAsync(playerkey, NumbersForSaving)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
DS:SetAsync("id_"..player.userId, {player.leaderstats.Points.Value, player.leaderstats.Prestige.Value})
end)
leaderstats
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "Points"
money.Value = 0
money.Parent = leaderstats
local money = Instance.new("IntValue")
money.Name = ("Prestige")
money.Value = 0
money.Parent = leaderstats
local money = Instance.new("BoolValue")
money.Name = "DoublePass"
money.Value = false
money.Parent = player
end)

4 comments
just to expand some more
its a top 10 points leaderboard
i want it to show the rank the name and the amount of points
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