dirk29
|
  |
| Joined: 26 May 2010 |
| Total Posts: 1142 |
|
|
| 27 Jan 2012 11:41 PM |
Why wont this work? function PlayersIntoTeams(Team1,Team2,TABLE) Int = 0 for i = 1,#TABLE do if Int == 0 then game.Players[TABLE[i]].TeamColor = BrickColor.new(Team1) --22 Int = 1 elseif Int == 1 then game.Players[TABLE[i]].TeamColor = BrickColor.new(Team2) Int = 0 end end end What i put PlayersIntoTeams("Bright blue","Bright red",Players) --Players is a table Output: 00:39:38 - Workspace.Main:22: bad argument #2 to '?' (string expected, got userdata) |
|
|
| Report Abuse |
|
|
dirk29
|
  |
| Joined: 26 May 2010 |
| Total Posts: 1142 |
|
| |
|
|
| 27 Jan 2012 11:57 PM |
| Give us line 22 of your script. The error doesn't seem to be in the function looking at the output. Unless the function is at line 22 but there it more code before it? Anyway, could you point out what ever is line 22? |
|
|
| Report Abuse |
|
|
Legend26
|
  |
| Joined: 08 Sep 2008 |
| Total Posts: 10586 |
|
|
| 28 Jan 2012 12:01 AM |
| It's because whatever is in TABLE[i] is the player object itself, not the name of the player. |
|
|
| Report Abuse |
|
|
|
| 28 Jan 2012 12:01 AM |
| Is Players = game.Players:GetChildren() ? |
|
|
| Report Abuse |
|
|
|
| 28 Jan 2012 12:02 AM |
Basicly I'd say what Legend said, since it'd be the player object.
Try TABLE[i].Name |
|
|
| Report Abuse |
|
|
Legend26
|
  |
| Joined: 08 Sep 2008 |
| Total Posts: 10586 |
|
|
| 28 Jan 2012 12:05 AM |
| Or better, just get rid of indexing the Players object altogether and do TABLE[i].TeamColor = BrickColor.new() |
|
|
| Report Abuse |
|
|
|
| 28 Jan 2012 03:45 AM |
I prefer to use for index, value in pairs(:GetChildren()) do I know that they're the same but its more easy on coding. |
|
|
| Report Abuse |
|
|