Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Only one player shows up on leaderboard?

HELLOOOO

Soo...I'm trying to make a leaderboard that shows the highest time someone has spent alive and who is #1 on the leaderboard. I have everything set out, but the problem is that instead of it showing all the players, it only shows 1 player. And they aren't even 1st place; they're 2nd. Help? I have it so that when a player leaves, I take their rank off the board.

Here is my script:

game.Players.PlayerRemoving:Connect(function(player)
	local labels = script.Parent:GetChildren()
	for _,label in pairs(labels) do
		if label:IsA("Frame") then
			if label.PlayerName.Text == player.Name then
				label:Remove()
			end
		end
	end
end)
wait(3)
while true do
	local list = game.Players:GetPlayers()
	table.sort(list, function(player1, player2)
		return player1.HighestTime.Value > player2.HighestTime.Value
	end)
	for i = 1,#list do
		local rank = "#"..i
		local Time = list[i].HighestTime.Value
		local name = list[i].Name
		local labels = script.Parent:GetChildren()
		for _,label in pairs(labels) do
			if label:IsA("Frame") then
				label:Destroy()
			end
		end
		local template = script.Template:Clone()
		template.Parent = script.Parent
		template.Name = i
		template.Rank.Text = rank
		template.Time.Text = Time
		template.PlayerName.Text = name
	end
	wait(5)
end

It's a normal script located in a part that's in workspace.

2 comments

1

Does the frame have UIListLayout inside of it? I ask because it could be because if there are 2 players, first gets added and without ListLayout the second gets added above the first, it's just a theory tho. Do you see all the frames inside of explorer?

0

I do have a UIListLayout. But when I look inside the SurfaceGui, it only has one frame.

1 answer

OH NVM I FIGURED IT OUT. I was getting the children inside the holder frame while putting on the names, so everytime it created one it deleted the others. RIP. I fixed it now tho.

This discussion is preserved as it was. New answers, comments, and votes are closed.