TeleportToPrivateServer
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 one or more Player|Players to a reserved server created using TeleportService/ReserveServer.
The reservedServerAccessCode parameter is the access code returned by TeleportService/ReserveServer|ReserveServer.
TeleportToPrivateServer can only be called on the server.
Spawn name
An optional spawnName parameter can be provided, which will cause the Player|Players to initially spawn at the SpawnLocation of that name in the destination place. The SpawnLocation must be valid for the Player|Players to spawn on. For example, it must be SpawnLocation/Neutral|neutral or set to the same SpawnLocation/TeamColor|TeamColor as the Team the Player|Players will be assigned to upon joining the game.
Teleport data
A teleportData parameter can be specified. This is data the clients 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.
You are advised to instead set the loading screen on the client using TeleportService/SetTeleportGui. The loading ScreenGui should also be parented to the Player|Player’s PlayerGui a few seconds before the teleport to ensure a smooth transition using a RemoteEvent. For an example of this see TeleportService/SetTeleportGui|SetTeleportGui
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 Places tutorial.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The ID of the place to teleport to |
||
|
|
The reserved server access code returned by |
||
|
|
An array of |
||
|
|
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
TeleportService: Teleport to a Reserved Server
The following code would send everyone in the current game to a reserved server. Since reserved servers can only be joined by using /TeleportService/TeleportToPrivateServer, nobody will join the reserved server afterwards.
Mind that, since everyone will be teleported, the current server will (probably) shutdown as nobody would be left in it.
TeleportService: Teleport to a Reserved Server via Chat
The following code would reserve one server, if it hasn’t be reserved before. Whenever someone says “reserved”, they will be teleported to the private server.