TeleportToSpawnByName
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 behaves the same as TeleportService/Teleport with the exception that it includes a spawnName parameter, causing the Player to spawn at the SpawnLocation of that name at 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 Team the Player will be assigned to upon joining the game.
The Player will still spawn at the correct SpawnLocation even the teleport is to a place in a different universe. The spawn will also be correct if Players/CharacterAutoLoads is false in the destination place and the Player/Character|Character is loaded manually using Player/LoadCharacter|LoadCharacter.
The teleportation will only affect the SpawnLocation used initially. If the Player respawns again subsequently it will not necessarily be at this SpawnLocation.
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 about teleporting please see
TeleportService/Teleportor theArticles/Teleporting Between Placestutorial
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
The ID of the place to teleport to |
||
|
|
The name of the |
||
|
nil
|
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:TeleportToSpawnByName
This code will teleport a player to Crossroads, and if there is a spawn named “TeleportSpawn” then the player would spawn on it. This assumes it’s being used in a /LocalScript.