I need to be able to send a GUI to all of the Players on a team. This is what I have so far.
1 | players = game.Players:GetChildren() |
2 | for i = #players, 1 do |
3 | if game.Players [ i ] .TeamColor = = game.Teams [ "My Team" ] .TeamColor then |
4 | gui = script.Parent.alarm_gui:clone() |
5 | gui.Parent = game.Players [ i ] .PlayerGui |
6 | end |
7 | end |
However it errors out here:
1 | if game.Players [ i ] .TeamColor = = game.Teams [ "My Team" ] .TeamColor then |
The Output says "1 is not a Valid member of Players"
Looks fine as far as I can tell, except line 2. For loops require that the lesser number goes last, so it should be:
1 | for i = 1 , #players do |
Another thing is that you're trying to refer to a table that doesn't exist when you say game.Players[i]. Since the loop is going through the players table you have already defined, it should be players[i].TeamColor, for instance.
Also, it's :Clone(), not clone(). That was just bugging me, it's really just proper syntax :P