I’m trying to make when the player clicks the GUI button it fires the remote event and teleports the player to another player in a different instance but the same game.
My current Event:game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("MessagingService").OnServerEvent:connect(function(player)
print(tonumber(script.PlayerUserId.Value))
local success, errorMessage, placeId, jobId = pcall(function()
return TeleportService:GetPlayerPlaceInstanceAsync(tonumber(script.PlayerUserId.Value))
end)
if success then
print("Success!")
-- Teleport player
TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
else
warn(errorMessage)
end
end)
local a, b, c, d = pcall(function()
return "1", "2", "3", "4"
end)
print(a) -- true
print(b) -- 1
print(c, d) -- 2, 3
-- 4 is nowhere to be found
Assume that placeId became errorMessage, placeId became jobId and jobId is missing.
Someone posted about the misleading example in the wiki, so they suggested a different method:
local teleSuccess, teleErrorMessage, placeId, jobId
local success, errorMessage = pcall(function()
teleSuccess, teleErrorMessage, placeId, jobId = TeleportService:GetPlayerPlaceInstanceAsync(followId)
end)
if success and teleSuccess then
-- do tele stuff
end
I made a bug report on this since the example on the api page was misleading.
The way you have it set up in your last reply is what I do. Be careful though, sometimes the pcall success will return nil even though it actually worked.
It may be safer to check if the placeid and jobid are not nil. (Unless this is fixed already)