TeleportToPlaceInstance
For thread safety, this property is not safe to read in an unsynchronized thread.
TeleportService/TeleportAsync|TeleportAsync, which should be used instead and may be used to:
- Teleport any number of players to a Public Server
- Follow a Friend to a Different Place
- Teleport any number of Players to a Reserved Server
This function teleports a Player to the place instance associated with the given placeId and instanceId. It can only be used to teleport to places in the same game.
The placeId is the DataModel/PlaceId of the server and the instanceId is the DataModel/JobId|JobId.
This function can not be used to teleport Player|Players to servers created using TeleportService/ReserveServer (reserved servers). For this, see TeleportService/TeleportToPrivateServer.
Spawn name
An optional spawnName parameter can be provided, which will cause the Player to initially spawn at the SpawnLocation of that name in the destination place. The SpawnLocation must be valid for the Player to spawn on. For example, it must be SpawnLocation/Neutral|neutral or set to the same SpawnLocation/TeamColor|TeamColor as the Team the Player will be assigned to upon joining the game.
Teleport data
A teleportData parameter can be specified. This is data the client will transmit to the destination place and can be retrieved using TeleportService/GetLocalPlayerTeleportData.
The teleportData can take any of the following forms:
- A table without mixed keys (all keys are strings or integers)
- A string
- A number
- A bool
As the teleportData is transmitted by the client it is not secure. For this reason it should only be used for local settings and not sensitive items (such as the users’ score or in-game currency).
If you need teleport data to persist across multiple teleports, you can use TeleportService/SetTeleportSetting and TeleportService/GetTeleportSetting.
Loading screen
A customLoadingScreen argument can be specified. This is a ScreenGui that is copied (without scripts) into the CoreGui of the destination place.
Note, TeleportService/SetTeleportGui is the preferred alternative to the customLoadingScreen argument as it can be called prior to the teleport.
The loading ScreenGui can be obtained in the destination place using TeleportService/GetArrivingTeleportGui, where developers can parent it to the PlayerGui.
Teleport failure
In some circumstances a teleport may fail. This can be due to the developer configuring the teleport incorrectly or issues with Roblox’s servers.
- If a teleportation request is rejected the
TeleportService/TeleportInitFailedevent will fire the error message and aEnum/TeleportResultenumerator describing the issue - Teleports can fail ‘in transit’, after the user has left the server, due to issues with Roblox’s servers. In this case the user will be shown an error message and be required to rejoin the game
Studio limitation
This service does not work during playtesting in Roblox Studio — To test aspects of your game using it, you must publish the game and play it in the Roblox application.
See also
- For more information on how to teleport players, see the
Articles/Teleporting Between Placestutorial.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The ID of the place to teleport to |
||
|
|
The |
||
|
nil
|
The |
||
|
|
Optional name of the |
||
|
|
Optional data to be passed to the destination place. Can be retrieved using |
||
|
nil
|
Optional custom loading screen to be placed in the |
Returns
| Return Type | Summary |
|---|---|
|
No return |
Code Samples
Following Another Player
The code sample below, when placed inside a Script within ServerScriptService, will teleport a player who’s following another player to the associated place/server. Note that this will not work if the player being followed is in a reserved server.