Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come this script isn't doing anything?

Asked by
Minifig77 190
10 years ago

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

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

Try calling it explicitly before the connections.

MakeList()
game.Players.PlayerAdded:connect(MakeList)
game.Players.PlayerRemoving:connect(MakeList)
Ad
Log in to vote
0
Answered by
wazap 100
10 years ago

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

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. Minifig77 190 — 10y
0
If this is in a LocalScript, just remember that game.Players.PlayerAdded and game.Players.PlayerRemoving arent very cooperative with LocalScripts wazap 100 — 10y

Answer this question