Global leaderboard not working

You can write your topic however you want, but you need to answer these questions:

  1. What do i want to achieve?
    I want to make a global leaderboard

  2. What is the issue?
    the leaderboard dosent work but i dont get any errors

This is the code:

local leaderbaord = game.Workspace.Map1.Leaderboards:WaitForChild("LeaderboardOOFS")

local SurfaceGui = script.Parent
local sample = script:WaitForChild("Sample")
local sf = SurfaceGui:WaitForChild("ScrollingFrame")
local ui = sf:WaitForChild("UI")
local Players = game:GetService("Players")

local dataStoreService = game:GetService("DataStoreService")
local ds = dataStoreService:GetOrderedDataStore("oofsLeaderboard")

wait(1)

while true do
	for i, plr in pairs(game.Players:GetChildren()) do
		if plr.UserId > 0 then
			local w = plr.leaderstats.OOFS.Value
			if w then
				pcall(function()
					ds:UpdateAsync(plr.UserId,function(oldval)
						return tonumber(w)
					end)
				end)
			end
		end
	end
	local smallestFirst = false
	local numberToShow = 100
	local minValue = 1
	local maxValue = 10e30
	local pages = ds:GetSortedAsync(smallestFirst,numberToShow,minValue,maxValue)
	
	local top = pages:GetCurrentPage()
	local data = {}
		
	for a,b in ipairs(top) do
		local userid = b.key
		local points = b.value
		
		local username = "[Failed to load]"
		
		local s,e = pcall(function()
			username = game.Players:GetNameFromUserIdAsync(userid)
			
		end)
		if not s then
			warn("Error getting name for"..userid.."Error: "..e)
		end

	end
	ui.Parent = script
	sf:ClearAllChildren()
	ui.Parent = sf
	for number, d in pairs(data) do
		local name = d[1]
		local val = d[2]
		local color = Color3.new(1,1,1)
		id = Players:GetUserIdFromNameAsync(name)
		if number == 1 then
			color = Color3.new(1,1,0)
		elseif number == 2 then
			color = Color3.new(0.666667, 0.666667, 0.666667)
		elseif number == 3 then
			color = Color3.new(0.552941, 0.305882, 0)
		end
		local new = sample:Clone()
		
		new.name = id
		new.LayoutOrder = number
		new.ImageLabel.playerName.Text = name
		new.ImageLabel.rank.Text = "#"..number
		new.ImageLabel.renk.TextColor3 = color
		new.ImageLabel.value.Text = val
		new.ImageLabel.value.TextColor3 = color
		new.ImageLabel.playerName.TextColor3 = Color3
		new.Parent = sf

	end
	wait(180)
	
	
end

Maybe because its reading nothing? Use the print function to debug.

i tried and it stops when it gets to this part:

	for a,b in ipairs(top) do
		local userid = b.key
		local points = b.value

So “b” returns nothing, right?

i think so i am not realy shure cuz i am new to lua

Print the variable “b”.

fdgfdgfsdggfd

i putted under

		local userid = b.key
		local points = b.value

and it just dosent print anything

Hmmmmmmmmm, what does “top” return also change from ipairs to pairs.

what do you mead by

what does “top”

also i’ve just changet to pairs

The top variable.

fdgtgetgdhtfdhxfhty

local top = pages:GetCurrentPage()

No, print the variable.

fffffffffffffffffffffffffffffffffffffff

15:55:28.659 {} - Server - Script:36
15:58:29.452 :arrow_forward: {…} - Server - Script:36
15:58:29.452 :arrow_forward: {…} - Server - Script:40

fffffffffffffffffffffffffffff

Open the table :confused:

hggfdhgstderfefffffffffffffffffffffffffffffffffff

{
[1] = :arrow_forward: {…}
} - Server - Script:36

this?

fffffffffffffff

Open the [1] table.

sdfffffffffffffffffffffff

                 }  -  Server - Script:36
  16:26:46.287   ▼  {
                    ["key"] = "1159156951",
                    ["value"] = 79
                 }  -  Server - Script:40

Everything seems fine. What about the gui creating thing.

its in the picture i sent

ffffffffffffff

you where right it was the gui i’ve set the position to high

Thanks