So in my game: Timed Obby, your goal is to complete different short obbys in the smallest amount of time and i want to make a global leader board that shows who completed it in the shortest amount of time.
The issue is that the person who took the longest to complete it will show up at the top, because its the highest value.
I already have a made the best time and a system to check if your current time is better than you best time and if it is it will change it.
Is there a way to invert the global leader board to make it show to smallest value at the top?
This is the global leader board code(I got the global leader board from a youtube named HowToRoblox):
--bgt means Best Green Time
local ds = game:GetService("DataStoreService")
local bgtODS = ds:GetOrderedDataStore("BestGreenTime")
local timeUntilReset = 10
while wait(1) do
timeUntilReset = timeUntilReset - 1
script.Parent.Parent.ResetTime.Text = "Resetting in " .. timeUntilReset .. " seconds..."
if timeUntilReset == 0 then
timeUntilReset = 10
for i, plr in pairs(game.Players:GetPlayers()) do
bgtODS:SetAsync(plr.UserId, plr.leaderstats.BGT.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 = bgtODS:GetSortedAsync(false, 50)
local bgtPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(bgtPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local BestGreenTime = dataStored.value
local template = script.Template:Clone()
template.Name = name .. "Leaderboard"
template.PlrName.Text = name
template.Rank.Text = "#" .. rankInLB
template.Coins.Text = BestGreenTime
template.Parent = script.Parent
end
end)
end
end
Any help will be appreciated.