Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TeleportService

Enables transporting Players between places and servers.

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 23

HistoryMember
553CustomizedTeleportUI: bool
573Block(): null
462GetArrivingTeleportGui(): Instance
462GetLocalPlayerTeleportData(): Variant
462GetPlayerPlaceInstanceAsync(userId: int64): Tuple
462GetTeleportSetting(setting: string): Variant
462ReserveServer(placeId: int64): Tuple
573SetTeleportGui(gui: Instance): null
573SetTeleportSetting(setting: string, value: Variant): null
573Teleport(placeId: int64, player: Instance = Instance, teleportData: Variant, customLoadingScreen: Instance = Instance): null
648TeleportAsync(placeId: int64, players: Instances, teleportOptions: Instance = Instance): Instance
573TeleportCancel(): null
648TeleportPartyAsync(placeId: int64, players: Instances, teleportData: Variant, customLoadingScreen: Instance = Instance): string
573TeleportToPlaceInstance(placeId: int64, instanceId: string, player: Instance = Instance, spawnName: string = , teleportData: Variant, customLoadingScreen: Instance = Instance): null
648TeleportToPrivateServer(placeId: int64, reservedServerAccessCode: string, players: Instances, spawnName: string = , teleportData: Variant, customLoadingScreen: Instance = Instance): null
573TeleportToSpawnByName(placeId: int64, spawnName: string, player: Instance = Instance, teleportData: Variant, customLoadingScreen: Instance = Instance): null
547UnblockAsync(): Tuple
462LocalPlayerArrivedFromTeleport(loadingGui: Instance, dataTable: Variant)
546MenuTeleportAttempt()
511TeleportInitFailed(player: Instance, teleportResult: TeleportResult, errorMessage: string, placeId: int64, teleportOptions: Instance)
inherited from Instance
553Archivable: bool
635Capabilities: SecurityCapabilities
553Name: string
553Parent: Instance
635Sandboxed: bool
616UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
486GetDescendants(): Array
486GetFullName(): string
641GetStyled(name: string): Variant
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
580IsPropertyModified(name: string): bool
573Remove(): null
576RemoveTag(tag: string): null
580ResetPropertyToDefault(name: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
648children(): Instances
553clone(): Instance
573destroy(): null
553findFirstChild(name: string, recursive: bool = false): Instance
648getChildren(): Instances
553isDescendantOf(ancestor: Instance): bool
573remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
553childAdded(child: Instance)
inherited from Object
647ClassName: string
647className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
650isA(className: string): bool
647Changed(property: string)

Removed member index 3

HistoryMember
210TeleportImpl(placeId: int, spawnName: string): void
311ConfirmationCallback(message: string, placeId: int, spawnName: string): bool
311ErrorCallback(message: string): void

Description

TeleportService is responsible for transporting Players between different places and servers.

For more information on how to teleport players between servers, see Teleporting Between Places.

History 86

Members 23

Block

Parameters (0)
No parameters.
Returns (1)
null

History 2

CustomizedTeleportUI

TypeDefault
bool

This property used to control whether or not a Message would be shown by default. The default message has been removed, so this no longer does anything.

This property is deprecated. It exists only for backward compatibility, and should not be used for new work.
This property is not replicated. Its interface does not cross the network boundary.

History 7

Tags: [NotReplicated, Deprecated]

GetArrivingTeleportGui

Parameters (0)
No parameters.
Returns (1)
Instance

This function returns the customLoadingScreen the LocalPlayer arrived into the place with.

Note, the customLoadingScreen will not be used if the destination place is in a different game.

Loading Screen

During a teleport, while the destination place is loading, the customLoadingScreen is parented to the CoreGui. Once the place has loaded the loading screen is parented to nil.

If you wish to preserve the customLoadingScreen and perform your own transitions, you will need to parent it to the local player's PlayerGui. For an example of this, see the code sample below.

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.

History 2

GetLocalPlayerTeleportData

Parameters (0)
No parameters.
Returns (1)
Variant

This function returns the teleport data the Players.LocalPlayer arrived with. It can only be called from the client.

Exploiters can spoof teleport data. Send secure data such as player currency through a server-side service such as DataStoreService to prevent tampering.

History 4

GetPlayerPlaceInstanceAsync

Parameters (1)
userIdint64
Returns (1)
Tuple

This function returns the PlaceId and JobId of the server the user with the given UserId is in, provided it is in the same game as the current place.

Then, TeleportService:TeleportToPlaceInstance() can be called with this information to allow a user to join the target user's server.

Upon a successful lookup, the function returns the following values:

#NameTypeDescription
1currentInstanceboolA bool indicating if the user was found in the current instance
2errorstringAn error message in the event of the lookup failing
3placeIdint64The PlaceId of the server the user is in
4instanceIdstringThe JobId of the server the user is in

If there is a problem during lookup, such as the user being offline, an error is thrown. It is recommended that you wrap calls to this function in pcall.

Limitations

You should be aware of the following limitations when using this function:

  • This function can only be called by the server.
  • This function may fail to return the correct information if the user is teleporting.
  • It is possible for this function to throw an error, hence developers should wrap it in a pcall() (see example below)
  • As this function returns the JobId of the server and not the access code returned by TeleportService:ReserveServer(), the id returned is not appropriate for use with reserved servers.

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.

This function yields. It will block the calling thread until completion.

History 3

Tags: [Yields]

GetTeleportSetting

Parameters (1)
settingstring
Returns (1)
Variant

This function retrieves a teleport setting saved using TeleportService:SetTeleportSetting() using the given key.

This method is intended for use on the client only and should not be used on the server.

Teleport settings are preserved across teleportations within the same game. This means data can be saved using TeleportService:SetTeleportSetting() in one place and retrieved using GetTeleportSetting in another place the user has been teleported to.

For example, in a game that allowed crouching you could save whether the user is currently crouching prior to teleporting as a teleport setting. This could then be retrieved in the destination place after the teleportation:

1
2
3
local TeleportService = game:GetService("TeleportService")

local isCrouching = TeleportService:GetTeleportSetting("isCrouching")

If no teleport setting exists under the given key, this function will return nil.

Differences from GlobalDataStores

Although they share some similarities, there are some key differences between teleport settings and datastores:

  • GlobalDataStore:SetAsync() stores the data on Roblox servers whereas SetTeleportSetting stores the data locally
  • Data stored in a GlobalDataStore is preserved after the user leaves the game universe whereas teleport settings are not
  • GlobalDataStores can only be accessed on the server, whereas teleport settings can only be accessed on the client
  • GlobalDataStores have usage limits, whereas teleport settings do not

In general teleport settings should be used to preserve client side information within a single play session across different places in a game. GlobalDataStores should be used to save important player data that needs to be accessed across player sessions.

Teleport settings and security

As teleport settings are stored locally, it is possible they can be manipulated by malicious users. This risk can be mitigated by employing server side validation.

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.

History 4

LocalPlayerArrivedFromTeleport

Parameters (2)
loadingGuiInstance
dataTableVariant

This function fires when the Players.LocalPlayer enters the place following a teleport. The teleportData and customLoadingScreen are provided as arguments.

When fetching teleportData and the customLoadingScreen you are advised to use TeleportService:GetLocalPlayerTeleportData() and TeleportService:GetArrivingTeleportGui() instead. This is because these functions can be called immediately without having to wait for this event to fire.

This event should be connected immediately in a LocalScript parented to ReplicatedFirst. Otherwise, when the connection is made the event may have already fired.

Loading Screen

During a teleport, while the destination place is loading, the customLoadingScreen is parented to the CoreGui. Once the place has loaded the loading screen is parented to nil.

If you wish to preserve the customLoadingScreen and perform your own transitions, you will need to parent it to the local player's PlayerGui. For example, using the following code inside a LocalScript in ReplicatedFirst:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
local TeleportService = game:GetService("TeleportService")
local Players = game:GetService("Players")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

TeleportService.LocalPlayerArrivedFromTeleport:Connect(function(customLoadingScreen, teleportData)
	local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")
	ReplicatedFirst:RemoveDefaultLoadingScreen()

	customLoadingScreen.Parent = playerGui
	-- animate screen here
	wait(5)
	-- destroy screen
	customLoadingScreen:Destroy()
end)

The customLoadingScreen will not be used if the destination place is in a different 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.

History 2

MenuTeleportAttempt

Parameters (0)
No parameters.

History 1

ReserveServer

Parameters (1)
placeIdint64
Returns (1)
Tuple

This function returns an access code that can be used to teleport players to a reserved server, along with the server's DataModel.PrivateServerId. It can only be called on the server.

Reserved Servers

You can access reserved servers using:

You can see if the current server is a reserved server by using the following code:

1
local isReserved = game.PrivateServerId ~= "" and game.PrivateServerOwnerId == 0

The DataModel.PrivateServerId is constant across all server instances associated with the server access code, the DataModel.JobId is not.

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.

Cross-Platform Play

Players on Xbox One with cross-platform play disabled will arrive in a different server with players with cross-platform play enabled. This can cause multiple game servers with the same PrivateServerId to exist.

This function yields. It will block the calling thread until completion.

History 4

Tags: [Yields]

SetTeleportGui

Parameters (1)
guiInstance
Returns (1)
null

This function sets the custom teleport GUI that will be shown to the local user during teleportation, prior to the teleport being invoked.

Note, the teleport GUI will not be used if the destination place is in a different game. It will also not persist across multiple teleports and will need to be set prior to each one.

This function should only be used on the client. If the teleportation function is called from the server (as is the case with TeleportService:TeleportAsync()) then this function should be called on the client prior to this. One way of doing this is listening to a RemoteEvent that fires several seconds before teleportation.

Loading screen

During a teleport, while the destination place is loading, the customLoadingScreen is parented to the CoreGui. Once the place has loaded the loading screen is parented to nil.

This ScreenGui can be fetched at the destination place using TeleportService:GetArrivingTeleportGui(), allowing you to parent it to the PlayerGui and perform your own transitions.

You are advised to also parent the ScreenGui to the PlayerGui in the start place while the teleport is initiating.

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.

History 3

SetTeleportSetting

Parameters (2)
settingstring
valueVariant
Returns (1)
null

This function stores a value under a given key that persists across all teleportations in the same game.

This method is intended for use on the client only and should not be used on the server.

The stored value can later be retrieved using TeleportService:GetTeleportSetting(). This will work in the current place and any subsequent places the Players.LocalPlayer teleports to, provided they are in the same game.

For example, in a game that allowed crouching you could save whether the user is currently crouching prior to teleporting as a teleport setting:

1
2
3
4
local TeleportService = game:GetService("TeleportService")

local isCrouching = false
TeleportService:SetTeleportSetting("isCrouching", isCrouching)

The stored value can take one of the following forms:

  • A table without mixed keys (all strings or all integers)
  • A string
  • A number
  • A bool

If data is already stored under the given key, the previous value will be overwritten by the new value.

Differences from GlobalDataStores

Although they share some similarities, there are some key differences between teleport settings and datastores:

  • GlobalDataStore:SetAsync() stores the data on Roblox servers whereas SetTeleportSetting stores the data locally
  • Data stored in a GlobalDataStore is preserved after the user leaves the game universe whereas teleport settings are not
  • GlobalDataStores can only be accessed on the server, whereas teleport settings can only be accessed on the client
  • GlobalDataStores have usage limits, whereas teleport settings do not

In general teleport settings should be used to preserve client side information within a single play session across different places in a game. GlobalDataStores should be used to save important player data that needs to be accessed across player sessions.

Teleport settings and security

As teleport settings are stored locally, it is possible they can be manipulated by malicious users. This risk can be mitigated by employing server side validation.

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.

History 5

Teleport

Parameters (4)Default
placeIdint64
playerInstanceInstance
teleportDataVariant
customLoadingScreenInstanceInstance
Returns (1)
null

This method should not be used for new work; the numerous teleport functions have been combined into a single method, TeleportAsync(), which should be used instead.

History 6

TeleportAsync

Parameters (3)Default
placeIdint64
playersInstances
teleportOptionsInstanceInstance
Returns (1)
Instance

This function serves as the all-encompassing method to teleport a player or group of players from one server to another. It can be used to:

  • Teleport players to a different place.
  • Teleport players to a specific server.
  • Teleport players to a reserved server.

Group Teleport Limitations

  • Groups of players can only be teleported within a single experience.
  • No more than 50 players can be teleported with a single TeleportService:TeleportAsync() call.

Potential Errors

This is a list of potential reasons a teleport may fail, ranging from invalid teleports to network issues.

ErrorDescription
Invalid placeIdThe provided place ID is below 0.
Players emptyThe provided list of players to teleport is empty.
List of players instances is incorrectAny of the provided players is not a Player object.
TeleportOptions not of correct typeThe provided teleportOption is not a TeleportOptions object.
TeleportAsync called from ClientThe client called TeleportAsync, which can only be called from the server.
Incompatible ParametersConflicting teleport options were used and TeleportService doesn't know where to send the player.

Conflicting TeleportOption parameters:
* ReservedServerAccessCode and ServerInstanceId
* ShouldReserveServer and ServerInstanceId
* ShouldReserveServer and ReservedServerAccessCode

For more information on how to teleport players between servers and receive user data from a teleport, see Teleporting Between Places.

This function yields. It will block the calling thread until completion.

History 3

Tags: [Yields]

TeleportCancel

Parameters (0)
No parameters.
Returns (1)
null

History 3

TeleportInitFailed

Parameters (5)
playerInstance
teleportResultTeleportResult
errorMessagestring
placeIdint64
teleportOptionsInstance

This event fires on both the client and the server when a request to teleport from a function such as TeleportService:TeleportAsync() fails and the player does not leave the current server. It provides a reason for the failure, as well as all of the information necessary to retry the teleport. If a group teleport fails, the event will fire once per player.

TeleportOptions

The TeleportOptions object provided by this event is not identical to the one passed to the original TeleportService:TeleportAsync() call. It is a new object populated with the necessary parameters to retry the teleport and send the player to the exact same destination. This is especially important for facilitating group teleports when they fail.

Original Teleport TypeTeleport DataReservedServerAccessCodeServerInstanceIdShouldReserveServer
Individual player to placeOriginal valueNoneNonefalse
Player(s) to reserved serverOriginal valueOriginal value, or the code generated if ShouldReserveServer was originally trueNonefalse
Player(s) to specific serverOriginal valueNoneOriginal valuefalse
Players to placeOriginal valueNoneSame destination ID as the other players in the original teleportfalse

For more information on how to teleport players between servers, see Teleporting Between Places.

History 3

TeleportPartyAsync

Parameters (4)Default
placeIdint64
playersInstances
teleportDataVariant
customLoadingScreenInstanceInstance
Returns (1)
string

This method should not be used for new work; the numerous teleport functions have been combined into a single method, TeleportAsync(), which should be used instead.

This function yields. It will block the calling thread until completion.

History 3

Tags: [Yields]

TeleportToPlaceInstance

Parameters (6)Default
placeIdint64
instanceIdstring
playerInstanceInstance
spawnNamestring
teleportDataVariant
customLoadingScreenInstanceInstance
Returns (1)
null

This method should not be used for new work; the numerous teleport functions have been combined into a single method, TeleportAsync(), which should be used instead.

History 6

TeleportToPrivateServer

Parameters (6)Default
placeIdint64
reservedServerAccessCodestring
playersInstances
spawnNamestring
teleportDataVariant
customLoadingScreenInstanceInstance
Returns (1)
null

This method should not be used for new work; the numerous teleport functions have been combined into a single method, TeleportAsync(), which should be used instead.

History 5

TeleportToSpawnByName

Parameters (5)Default
placeIdint64
spawnNamestring
playerInstanceInstance
teleportDataVariant
customLoadingScreenInstanceInstance
Returns (1)
null

This method should not be used for new work; the numerous teleport functions have been combined into a single method, TeleportAsync(), which should be used instead.

History 6

UnblockAsync

Parameters (0)
No parameters.
Returns (1)
Tuple
This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

Removed members 3

ConfirmationCallback

Parameters (3)
messagestring
placeIdint
spawnNamestring
Returns (1)
bool

History 3

Tags: [NoYield]

ErrorCallback

Parameters (1)
messagestring
Returns (1)
void

History 3

Tags: [NoYield]

TeleportImpl

Parameters (2)
placeIdint
spawnNamestring
Returns (1)
void

History 2

Settings