We use cookies on this site to enhance your user experience

Teleporting the local player

Teleporting the local player

Sep 11 2018, 3:08 AM PST

This snippet demonstrates how TeleportService can be used to teleport the Players/LocalPlayer|LocalPlayer from the client.

It also shows how TeleportService/SetTeleportGui can be used to define a custom loading GUI. Note, this ScreenGui will need to be retrieved at the destination place using TeleportService/GetArrivingTeleportGui and be parented to the PlayerGui.

local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local playerGui = Players.LocalPlayer:WaitForChild("PlayerGui")

local placeId = 0 -- replace here
local loadingGui = ReplicatedStorage:FindFirstChild("LoadingGui") -- replace here

-- parent the loading gui for this place
loadingGui.Parent = playerGui

-- set the loading gui for the destination place

-- teleport the user