TeleportPartyAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts.
This function teleports a group of Player|Players
to the same server instance in the given place. It returns the DataModel/JobId
of the server instance the players were teleported to.
This function can only be called from the server.
You may only use this function to teleport to a place in the same game. This function can not teleport more than 50 Player|Players
in a single party.
Currently this function may not work reliably when teleporting Player|Players
to the same place they are currently in.
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).
Loading screen
A customLoadingScreen argument can be specified. This is a ScreenGui
that is copied (without scripts) into the CoreGui
of the destination place. It can be retrieved at the destination place using TeleportService/GetArrivingTeleportGui
and will not be used if the destination place is in a different game.
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|Players'
PlayerGui|PlayerGuis
a few seconds before the teleport to ensure a smooth transition using a RemoteEvent
. For an example of this see TeleportService/SetTeleportGui|SetTeleportGui
.
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/TeleportInitFailed
event will fire the error message and aEnum/TeleportResult
enumerator 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
Player/GetJoinData
to get thePlayer/UserId|UserIds
ofPlayer|Players
teleported together
Parameters
Name | Type | Default | Description |
---|---|---|---|
|
The ID of the place to teleport to |
||
|
An array containing 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 |
---|---|
The |
Code Samples
Teleport all players in the server
This code sample is an example of how TeleportService/TeleportPartyAsync
can be used to teleport a group of Player|Players
.
In this case, all Player|Players
will be teleported to the specified placeId as a party. The DataModel/JobId
of the destination server is then printed.