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
This function can not be used to teleport
Player|Players to servers created using
TeleportService/ReserveServer (reserved servers). For this, see
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
Player will be assigned to upon joining the game.
A teleportData parameter can be specified. This is data the client will transmit to the destination place and can be retrieved using
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
A customLoadingScreen argument can be specified. This is a
ScreenGui that is copied (without scripts) into the
CoreGui of the destination place.
TeleportService/SetTeleportGui is the preferred alternative to the customLoadingScreen argument as it can be called prior to the teleport.
ScreenGui can be obtained in the destination place using
TeleportService/GetArrivingTeleportGui, where developers can parent it to the
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 a
Enum/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
For more information on how to teleport players, see the
Articles/Teleporting Between Places tutorial.
The ID of the place to teleport to
Optional name of the
Optional data to be passed to the destination place. Can be retrieved using
Optional custom loading screen to be placed in the
Following a Player in a Game Universe
The code sample below, when placed inside a
ServerScriptService will teleport users following another user to the place and server that user is in. Note, this will not work if the user is in a reserved server.
local TeleportService = game:GetService("TeleportService") local Players = game:GetService("Players") Players.PlayerAdded:Connect(function(player) -- is this player following anyone? local followId = player.FollowUserId if followId then -- if so find out where they are pcall(function() local success, errorMessage, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId) -- have we found this player? if success then -- if so teleport TeleportService:TeleportToPlaceInstance( placeId, jobId, player ) end end) end end)