|
| 31 May 2014 04:06 PM |
Why doesn't it work?
players = game.Players:GetChildren()
players[math.random(1,players.NumPlayers)]:MoveTo(Vector3.new(game.Workspace.Player1Teleport.Position)) players[math.random(1,players.NumPlayers)]:MoveTo(Vector3.new(game.Workspace.Player2Teleport.Position))
Thanks. |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
| |
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 31 May 2014 04:11 PM |
GetChildren returns a table, which do not have properties
Then you tried to index NumPlayers as a property of the 'players' table, which is a table and not the actual Player service itself.
Try this:
players = game.Players:GetPlayers() -- Use GetPlayers so it only searches for the player object
players[math.random(1, #players)]:MoveTo(workspace.Player1Teleport.Position) players[math.random(1, #players)]:MoveTo(workspace.Player2Teleport.Position) -- You can use #[table] to return the number of objects in that table -- No reason to cast a position as a new Vector3, because it's already a V3 value |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 04:11 PM |
Thanks for the help, but still doesn't work. The error is "bad argument #2 to 'random' (interval is empty)". |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 31 May 2014 04:13 PM |
| Basically means there aren't any players. If you're using this in studio, make sure you code a check to make sure that #players > 0 |
|
|
| Report Abuse |
|
|
|
| 31 May 2014 04:31 PM |
Doesn't work but thanks. Do I add the if condition to the script? |
|
|
| Report Abuse |
|
|
| |
|