Leaderboard script won't work?

Hello, I am making a leaderboard for my game but I have ran into a problem; Half of the script won’t work, and there’s nothing in the output. I have no clue what the issue could be, but here’s the script
Script:

local DS = game:GetService("DataStoreService")
local pageSize = 10
local first = script.Parent:WaitForChild("InvBackground")
local second = script.Parent:WaitForChild("Second")
local values = {
	["1"] = Color3.fromRGB(151, 153, 7),
	["2"] = Color3.fromRGB(113, 113, 113),
	["3"] = Color3.fromRGB(154, 89, 51)
}
local defaultColor = Color3.fromRGB(206, 206, 206)
local orderedStore = DS:GetOrderedDataStore("CashMoney_.",pageSize)
function leaderboard()
	local sortSync = orderedStore:GetSortedAsync(true,pageSize)
	local currentPage = sortSync:GetCurrentPage()
	print("Works?") -- prints
	print(currentPage) -- prints {}
	for rank,data in ipairs(currentPage) do
		print(rank .. data) -- doesnt print
		local name = data.key
		local points = data.value
		for i = 1,pageSize,1 do
			local nameAndRank = Instance.new("TextLabel",first)
			nameAndRank.Size = UDim2.fromScale(150,50)
			nameAndRank.BackgroundTransparency = 1
			nameAndRank.TextSize = 30
			nameAndRank.Font = Enum.Font.TitilliumWeb
			nameAndRank.Text = name .. " #" .. rank
			local colorValue = values[tostring(rank)]
			print("Success.") -- doesnt print
			local pointsText = Instance.new("TextLabel",second)
			pointsText.Size = UDim2.fromScale(100,50)
			pointsText.BackgroundTransparency = 1
			pointsText.TextSize = 30
			pointsText.Font = Enum.Font.TitilliumWeb
			pointsText.Text = points
			if colorValue then
				nameAndRank.TextColor3 = colorValue
				pointsText.TextColor3 = colorValue
			else
				nameAndRank.TextColor3 = defaultColor
				pointsText.TextColor3 = defaultColor
			end
		end
	end
end

leaderboard()

I have datastore set up, I have API services in studio on, I have progress data in the game; I could not possibly figure out the problem, so help will be appreciated.

Nevermind, I had to set the value again when the player joins.

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