Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you use the localplayer when teleporting?

Can you use the LocalPlayer when teleporting?

1 comment

0

No. Teleporting from server to server cannot be done from the client.

1 answer

✓ Accepted answer

Well i don't really know what you meant by that but here an example hope this is what you're looking for!

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
TeleportService:SetTeleportGui(loadingGui)
 
-- teleport the user
TeleportService:Teleport(placeId)

^^ From roblox's source ^^

2 comments

0

I understand most of it, however i cant understand the playerGui part, can you explain it for me. I will remember to accept your answer.

1

Well that's a custom thing example as if you want them to have like an custom loading screen while getting teleported then you shall use that, if not just remove the "TeleportService:SetTeleportGui(loadingGui)" part with the "local loadinggui" and "loadingGui.Parent = playerGui" ,it will still tp but without having a custom GUI with it.

This discussion is preserved as it was. New answers, comments, and votes are closed.