Issues with OrderedDataStore

I’ve been working on a leaderboard using OrderedDataStores but I genuinely can’t figure out why it doesn’t work. I have no errors in the output- after attempting to use the debugger I found out that everything below line 17 (for i,v in pairs(Page) do) doesn’t “trigger” at all.

local DataStoreService = game:GetService("DataStoreService")
local TokenData = DataStoreService:GetOrderedDataStore("TokenDataStore")
local Players = game:GetService("Players")

for i = 1,10 do
	local Line = script.LineEx:Clone()
	Line.Name = i
	Line.Parent = script.Parent.Front.Frame
	Line.Text = "N/A"
	Line.LayoutOrder = i
end


while true do
	local SortedStore = TokenData:GetSortedAsync(false, 10)
	local Page = SortedStore:GetCurrentPage()
	for i,v in pairs(Page) do
		print("Fired")
		local Username = Players:GetUserIdFromNameAsync(v.key)
		local UserId = v.key
		local Place = i
		local Value = v.value
		script.Parent.Front.Frame.i.Text = "#".. tostring(Place) [game.Players:GetNameFromUserIdAsync(UserId)] .. Value .. "Tokens"
	end
	wait(60)
end

Please explain why it doesn’t work when providing a solution so I can learn from it. I’m still pretty new to Lua and Datastores in general. Thanks in advance.

2 Likes

My mistake, my data is stored in a regular Datastore, and not an OrderedDataStore. I thought OrderedDataStore was simply an ordered version of the same Datastore. Due the issues with the Developer Hub some confusion was made.