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

Help with a Custom Leaderboard Gui?

Hey, guys. I was trying to make a Custom Leaderboard Gui, but I got stuck because it wouldn't work right. The Gui is in this form: StarterGui > ScreenGui > Frame > Script. There is also a TextLabel inside ServerStorage. What my script was suppose to do was clone the TextLabel from ServerStorage into the Frame, as much times as there are the number of players, and make the text for all those TextLabels, all the players in the games' names.

local Player = script.Parent.Parent.Parent.Parent
local x = script.Parent
Template = game.ServerStorage.LeaderboardTemplate:clone()
Players = game.Players:GetChildren()
num = 35
playas = 0
while true do
	for i = 1, #Players do
		print(#Players)
		if playas < 8 then
			playas = playas +1
			T2 = Template:clone()
			T2.Parent = x
			T2.Position = T2.Positoin + UDim2.new(0, 0, 0, num)
			T2.Name = "PlayerButton"
			T2.Text = Players[i].Name
		end
	end
end

If anyone could explain to me what I did wrong, it would be very helpful!

2 comments

0

Local scripts can't "see" inside server storage. Instead, you should use replicated storage. Also, game.Players.LocalPlayer is an easier way to get the player in local scripts.

0

Thank you for the replicated storage tip!

1 answer

Please remove the "#" from the word "Player" so it will work, you called it "Player" not "#Player".

1 comment

0

He did #Players as in the number of values in the "Players" table. That's how lots of generic for loops that change all the players in the game work.

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