Teleporting Between Places

Teleporting Between Places

5 min

Very large worlds may perform better when teleportation is implemented. For instance, if a fantasy world has several towns, a castle, multiple large dungeons, and a haunted forest, you should make each a separate place and teleport players between them at specific points (like a dungeon’s entrance/exit).

In Roblox, teleportation is handled by TeleportService. This can be used to teleport players between places in a game or even to another game.

Getting a Target ID

Most of the functions in TeleportService require the ID of the target place or game. If the destination place is in the same game as the origin place, the ID can be obtained from the Game Explorer by expanding the Places tree, right-clicking the place, and selecting Copy ID to Clipboard.

Alternatively, if the teleport destination is another game, the ID can be copied from the URL of game’s main page on roblox.com.

Valid Teleport Destinations

TeleportService limits teleportation to places in the same game or to the starting place of another game (assuming the owner has made it public).

Data Persistence

When a player is teleported between places, any custom data associated with that player is discarded. Thus, it’s very important that you consider data persistence when using TeleportService.

  • If players utilize any amount of secure custom data in your game, for example health, in-game currency, complex player stats, and/or a large inventory of items, /articles/Data store|data stores should be implemented to maintain data as players teleport from place to place.

  • If just a small amount of non-secure data should be retained, like game settings and UI theme, the TeleportService functions accept a teleportData parameter. This can be a table, string, number, or boolean which can then be retrieved in the destination place via TeleportService/GetLocalPlayerTeleportData|GetLocalPlayerTeleportData().


Teleport on Part Touch

In this example, TeleportService/Teleport|Teleport() is used to teleport players who touch the script’s parent part.

Follow 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.

  • teleport
  • place
  • transport