Currentpage for loop is ignored or not working

I have tried changing and kept switching things with my script and its still not working

everything prints except what is inside for loop which for loop is refusing to loop inside CurrentPage anyone knows why?

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local TransferLeaderboardData = ReplicatedStorage.TransferLeaderboardData
local Datastore = game:GetService("DataStoreService")
local DonatorsDatastore = Datastore:GetOrderedDataStore("Top20Donators")
-------------------------
local Cooldown = true
local RefreshInterval = 5
local donatorsShown = 20
-------------------------



TransferLeaderboardData.OnServerInvoke = function(player, ScrollingFrame)	
	if Cooldown then
		Cooldown = false
		------------------------- Refreshing
		for i,v in pairs(ScrollingFrame:GetChildren()) do
			if v:IsA("Frame") then
				v:Destroy()
			end
		end
		print("Refreshing ended")
		loopThroughpages(player, ScrollingFrame)
		print("will wait "..RefreshInterval)
		task.wait(RefreshInterval)
		Cooldown = true
	end
end

function loopThroughpages (player, ScrollingFrame)
	local pages: DataStorePages = DonatorsDatastore:GetSortedAsync(false, donatorsShown, 1, 2^63)
	local CurrentPage = pages:GetCurrentPage()
	print("Starting for loop")
	for rank, data in pairs(CurrentPage) do 
		print("getting rank and data")
		local userId = data.key
		local DonatedAmount = data.value
		print("Mid for loop")
		local slot = ServerStorage.Rank:Clone()
		slot.Name = player.Name
		slot.Robux.Text = DonatedAmount
		slot.LayoutOrder = rank
		slot.Parent = ScrollingFrame
		print("Cloned and changed")
	end
end

Maybe because there is no current page? But I’m not sure and cannot provide any more detail.

Nevermind I was just having dead brain while testing :skull: already found th solution

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.