|
| 16 Nov 2014 10:22 PM |
I haven't scripted in lua for a while, so I'm a little dusty. How would I loop through all the players in a game and teleport them to a given location?
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Nov 2014 10:26 PM |
local givenLocation = Vector3.new(0, 0, 0); local players = game:GetService("Players"):GetPlayers();
for key = 1, #players do local value = players[key]; if value.Character then value.Character:MoveTo(givenLocation); end end |
|
|
| Report Abuse |
|
|
|
| 16 Nov 2014 10:28 PM |
| Cntkillme why don't you use in pairs()? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 16 Nov 2014 10:32 PM |
| I don't know, I mean I know using a numerical loop is _barely_ any more efficient but it just became a habit. |
|
|
| Report Abuse |
|
|