I have a system in my game where a player is transported to a private server, completes some task, then returns to the same server that they are in.
This works perfectly until I try to send them back to the same server that they were in.
When the player joins the private server, the jobId of the server they were just in is sent with them, and is used when they try to return.
The problem is that if I try use the serverid, I get an unknown exception and teleport fails, as soon as I comment this part out. It works fine (just that it doesnt return them to the same server). The wiki says if it cant find the server, it makes a new one but it seems to just error instead.
I’ve verified the JobId is correct and that when I remove the ServerInstanceId property of the TeleportOptions that it works with no problems.
Network.Listen("Return", function(player, info)
local lastServerInstanceId = info.lastServerInstanceId
local lastPlaceId = info.lastPlaceId
local lastPosition = info.lastPosition -- irrelevant, just used to place the character in correct position when they return
local teleportOptions = Instance.new("TeleportOptions")
teleportOptions.ServerInstanceId = lastServerInstanceId
teleportOptions.ShouldReserveServer = false
teleportOptions:SetTeleportData(info)
print(lastServerInstanceId, lastPlaceId)
-- does print valid jobid and placeid
local s, e = pcall(function() -- the idea is that if it fails here, to ditch going to original server
TeleportService:TeleportAsync(
lastPlaceId,
{player},
teleportOptions
)
end)
if not s then -- but even when i disable that, it still has same error, its like it doesnt let me change the teleport options property, but it shouldn't be causing issues to begin with
teleportOptions.ServerInstanceId = "" -- I also tried setting this to nil
TeleportService:TeleportAsync(
lastPlaceId,
{player},
teleportOptions
)
end
end)