I made a global leaderboard yesterday for fastest time to complete a level. The problem is, everyone who has data that is 0 (which means they haven’t played the level yet), are at the top. (because it is 0, in that case the fastest time.)
If this game ever gets popular, and even now, this is a big problem. Here’s the script, thank you to anyone who helps find the solution!!
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.ResetTime.Text = "Updating in " .. timeUntilReset .. " seconds"
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
ODS1:SetAsync(plr.UserId, plr.Scores.BlueCoaster.HighScore.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 = ODS1:GetSortedAsync(true, 100)
local timePage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(timePage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local time = dataStored.value
local string = ODS2:GetAsync("Player_" .. tonumber(dataStored.key))
local template = script.Template:Clone()
template.Parent = script.Parent
template.Name = name .. "Leaderboard"
template.PlrName.Text = name
template.Rank.Text = "#" .. rankInLB
template.Wins.Text = decodetimer(string)
end
end)
end
end