|
| 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
|
  |
| Joined: 14 Oct 2010 |
| Total Posts: 4969 |
|
|
| 30 Mar 2013 08:17 PM |
Character:MoveTo(Vector3PositionHere)
|
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 30 Mar 2013 08:22 PM |
| Thank you very much, Solotaire. That was exactly what I was looking for. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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 |
|
|