Here's the code it works for 1 player (assuming the topplr), but for some reason once I added the clean() function it just wont even display. I have 2 main problems, the leaderboard won't function correctly and it wont display at all when I want to clean it. It also doesn't want to update. There are no output errors, I checked and fixed them all.

wait(5)
local board = workspace.Fencing.SurfaceGui
local list = board.plrslist
local plr = script.name
local posy = 1
local topplr

function clean()
	for _,v in pairs(list:GetChildren()) do
		if v.Name == "name" then
			v:Destroy()
		end
	end
end

function update()
	clean()
	for _,v in pairs(game.Players:GetPlayers()) do
		local plrr = plr:clone()
		local ls = v:WaitForChild("leaderstats")
		if topplr == nil then
			topplr=v
			plrr.Parent=list
			plrr.Text=topplr.Name
			plrr.wins.Text = ls.Wins.Value
			plrr.spree.Text = ls.Spree.Value
			plrr.rank.Text = "Starter"
			plrr.Position = UDim2.new(0,0,1,0)
		elseif topplr ~= nil and topplr.leaderstats.Wins.Value > v.leaderstats.Wins.Value and topplr ~= v then
			posy=posy+0.5
			plrr.Parent=list
			plrr.Text=v.Name
			plrr.wins.Text = ls.Wins.Value
			plrr.spree.Text = ls.Spree.Value
			plrr.rank.Text = "Starter"
			plrr.Position = UDim2.new(0,0,posy,0)
		elseif topplr ~= nil and v.leaderstats.Wins.Value > topplr.leaderstats.Wins.Value and topplr ~= v then
			topplr=v
			plrr.Parent=list
			plrr.Text=v.Name
			plrr.wins.Text = ls.Wins.Value
			plrr.spree.Text = ls.Spree.Value
			plrr.rank.Text = "Starter"
			plrr.Position = UDim2.new(0,0,1,0)		
		end
	end
	posy=1
end

while wait() do
update()
end

3 comments

0

By 1 player I mean the first player that joins the game.

0

Try adding a delay in your while loop (e.g. while wait(10) do). The leaderboard is clearing itself right after it updates, which explains why nothing is showing.

0

it shows but it doesnt update the 2nd time meaning it shows the first time then it just doesnt want to work anymore