Can someone help me rq, global leaderboard problems

Ok so, im working on a global leaderboard and there’s a error that i can’t figure out on what’s happening, the code is:

--  Services

local DataStore = game:GetService("DataStoreService")
-- Variables

local sf = script.Parent.ScrollingFrame
local Template = script.Sample
local dataStore = DataStore:GetOrderedDataStore("Clicks")
local ui = sf.UI

wait(5)

while true do
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.UserId > 0 then
			local status = v:FindFirstChild("Stats")
			local Coins = status:FindFirstChild("Coins")
			if status and Coins then
				pcall(function()
					dataStore:SetAsync(v.UserId,Coins.Value)
					print("updated")
				end)
			end
		end
	end
	
	local smallestFirst = false
	local numberToShow = 15
	local minValue = 1
	local pages = dataStore:GetSortedAsync(smallestFirst, numberToShow)
	local top = pages:GetCurrentPage()
	
	local data = {}
	print(top)
	for a,b in ipairs(top) do
    -- More of the code here

Ok, everything working fine but when it comes to the for loop in the “top” table it basically returns nothing, and if i print top it actually return nothing too. Already tested to see if the first for is saving the coins value and yes it’s saving, i used the debug tool to test it.

I would check out this post.

Already did, i made mine with this post. But i can’t figure out what’s hapenning to mine

The same script just worked on another place, i really don’t know what’s going on lol

Ah, I see…I’m not too sure.

30charlimit

Sorry for the wait but basically it was returning a error while trying to save because Ordered Data Stores didnt save non Integer numbers

1 Like