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?
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