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: How to teleport players?

Previous Thread :: Next Thread 
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
30 Mar 2013 08:13 PM
How could I teleport players?

More specifically, I want to make a fun FFA place, and I want to teleport players from the lobby, to random locations on the map.

Thanks.
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
30 Mar 2013 08:17 PM
Character:MoveTo(Vector3PositionHere)
Report Abuse
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
30 Mar 2013 08:20 PM
A model (such as a player's character) can be moved all at once using the MoveTo function. This is ideal over other options such as editing the CFrame of every descendant of the model. This is especially true for moving a character, as detaching the head will cause a Wipeout.

The MoveTo function takes one command, which is a Vector3 location.
For example, we could do
character:MoveTo(Vector3.new(0,0,0)) to bring them right to the center of the map.

If the Vector3 passed in is a brick, the model will move to the X and Z location of the brick, and to the Y+ location of the brick, so as to put it above the brick.

You can read more about it here:
http://wiki.roblox.com/index.php/MoveTo
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
30 Mar 2013 08:22 PM
Thank you very much, Solotaire. That was exactly what I was looking for.
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
30 Mar 2013 08:40 PM
For some reason, this won't work:

wait(10)

a = game.Players:GetChildren()
if a then
a:MoveTo(Vector3.new(3, 2.8, 24))
end


Help?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
30 Mar 2013 08:42 PM
wait(10)
a = game.Players:GetChildren() -- Table of players
for _, v in pairs(a) do -- _ beings the place in the table and v being the object
v.Character:MoveTo(Vector3.new(3, 2.8, 24)) -- move the character model
end
Report Abuse
fireflame09225 is not online. fireflame09225
Joined: 04 Jan 2010
Total Posts: 1818
30 Mar 2013 08:46 PM
Thank you! :]
Report Abuse
Solotaire is not online. Solotaire
Joined: 30 Jul 2009
Total Posts: 30356
30 Mar 2013 08:47 PM
An error occurs here:
a:MoveTo(Vector3.new(3, 2.8, 24))

game.Players:GetChildren() returns a table of all players in the game. You are trying to move the players to that location. The error comes for two reasons:
1) The statement is trying to move the table.
2) You are moving the players, not the characters.

Here's what you are looking for, I believe:
-- while true do
wait(10)
for _,v in pairs(game.Players:GetChildren()) do
v.Character:MoveTo(Vector3.new(3,2.8,4))
end
-- end

The above code used a Generic For loop (caps given to differentiate the word "generic" from "general"-- the term is a generic for). It loops through the table of players and then moves their characters to the position.

You can read more about the generic for here: http://wiki.roblox.com/index.php/Generic_for
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