Ordered Data store not working

So I have this global leader board for my game and i want to change it to ascending order.

When i turn the ascending boolean value to true, it nothing shows up.

I’m trying to make the global leader boards show the lowest value at the top instead of the highest value

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

This is the code:

--Bgt mean 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) -- When i change the false to true nothing shows up.
			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

Thanks for reading

1 Like