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

How come this script isn't doing anything?

I'm making a GUI that is a list of all players on the server. I proceeded to test it, and it didn't do anything. There was nothing in the output. I figured out that it was the PlayerAdded event, and the actual function worked.

Here is the code:

function MakeList()
	print("Making list")
	Players = game.Players:GetChildren()
	for i = 1, #Players do
		btn = script.Parent.Parent.TextButton:Clone()
		print("Button cloned.")
		btn.Parent = script.Parent
		print("Button moved.")
		btn.Text = Players[i].Name
		btn.Visible = true
	end
end
game.Players.PlayerAdded:connect(MakeList)
game.Players.PlayerRemoving:connect(MakeList)

I also tried:

function MakeList()
	print("Making list")
	Players = game.Players:GetChildren()
	for i = 1, #Players do
		btn = script.Parent.Parent.TextButton:Clone()
		print("Button cloned.")
		btn.Parent = script.Parent
		print("Button moved.")
		btn.Text = Players[i].Name
		btn.Visible = true
	end
end
game.Players.PlayerAdded:connect(function()
	MakeList()
end)

Why are neither of these doing anything when a player enters the game?

2 answers

Try calling it explicitly before the connections.

MakeList()
game.Players.PlayerAdded:connect(MakeList)
game.Players.PlayerRemoving:connect(MakeList)

Maybe because all the TextButtons are overlapping each other so the one on the top is the only one that shows. Also, you never removed the old buttons

2 comments

0

I did realize that, but I decided to take it one step at a time. There are no text buttons inside the directory it clones to. When a player joins the game, the function, for some reason, doesn't fire, and therefore no textboxes even are put into that directory.

0

If this is in a LocalScript, just remember that game.Players.PlayerAdded and game.Players.PlayerRemoving arent very cooperative with LocalScripts

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