generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: player teleport

Previous Thread :: Next Thread 
FroggoBLOX is not online. FroggoBLOX
Joined: 22 Sep 2012
Total Posts: 5483
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 is not online. 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
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
16 Nov 2014 10:28 PM
Cntkillme why don't you use in pairs()?
Report Abuse
cntkillme is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image