Im not sure what values to change to what.
heres the LeaderboardHandler
local ds = game:GetService("DataStoreService")
local PointsODS = ds:GetOrderedDataStore("leaderstats")
local timeUntilReset = 10
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.Additional.ResetTimeT.Text = "Resetting In " .. timeUntilReset .. " Seconds..."
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
PointsODS:SetAsync(plr.UserId, plr.leaderstats.Points.Value)
end
for i, leaderboardRank in pairs(script.Parent==:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = PointsODS:GetStoredAsync(false, 50)
local PointsPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(PointsPage) do
local Name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.savevalue1))
local Points = dataStored.value
local template = script.Template:Clone()
template.name = Name .. "Leaderboard"
template.PlrName.Text = Name
template.Rank.Text = "#" .. rankInLB
template.Points.Text = Points
template.Parent = script.Parent
end
end)
end
endlocal ds = game:GetService("DataStoreService")
local PointsODS = ds:GetOrderedDataStore("leaderstats")
local timeUntilReset = 10
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.Additional.ResetTimeT.Text = "Resetting In " .. timeUntilReset .. " Seconds..."
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
PointsODS:SetAsync(plr.UserId, plr.leaderstats.Points.Value)
end
for i, leaderboardRank in pairs(script.Parent==:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = PointsODS:GetStoredAsync(false, 50)
local PointsPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(PointsPage) do
local Name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.savevalue1))
local Points = dataStored.value
local template = script.Template:Clone()
template.name = Name .. "Leaderboard"
template.PlrName.Text = Name
template.Rank.Text = "#" .. rankInLB
template.Points.Text = Points
template.Parent = script.Parent
end
end)
end
end
heres the savedata
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)
heres the 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
Please respond as this will be an update to my game
is this your code
yes
i got the leaderboard from a tut because i had no clue how to make one