TeleportToPlaceInstanceFunction of TeleportService
void TeleportToPlaceInstance ( int64 placeId, string instanceId, Player player = nil, string spawnName = "", Variant teleportData, ScreenGui customLoadingScreen = nil )Parameters:
Description: Will teleport the given player to a specific place instance given a placeId and an instanceId. Will error if attempted on a place instanceId not within the calling place's Game. The given teleportData can be any value that can be stored in a datastore, and will be transported along with the player. The customLoadingScreen is a GUI that'll be made static (scripts don't run, TweenPosition etc doesn't work, ...) and displayed during teleporting. You can see these arguments after the player has been teleported, using LocalPlayerArrivedFromTeleport.
- The JobId property of the DataModel is the server's instanceId.
- The teleportData parameter can be excluded, as Variants can be nil.
When being used server-side the character needs to be specified. The below example assumes there's a player in your game named "Telamon".
local TeleportService = game:GetService("TeleportService") local Success, Error, placeId, instanceId = TeleportService:GetPlayerPlaceInstanceAsync(1) if Success then TeleportService:TeleportToPlaceInstance(placeId, instanceId, game.Players.Telamon) else print(Error) end
If using this client-side (LocalScript) then you would omit the usage of the third argument, and only provide the placeId and instanceId.