Hello, I got a problem. I made a teleport code that teleports the player to the server another player in.
But I got an error like this:
Here’s the code (is server script):
local event_accept = event:FindFirstChild("ModcallAccepted")
function AcceptModcall(plr, userId)
local serverPlayerIn = service:GetPlayerPlaceInstanceAsync(userId)
service:TeleportToPlaceInstance(game.PlaceId, serverPlayerIn, plr)
end
event_accept.OnServerInvoke = AcceptModcall
GetPlayerPlaceInstanceAsync actually returns four things. You’ll need the last two to get the PlaceId and the ServerId. The code is attempting to use a status message as the ServerId.
It’d be wiser to use the returned PlaceId value over game.PlaceId (if I suggested that in the past, my bad). game.PlaceId would just redirect to the current place. Ideally, for a mod call system, you want to use both.
local event_accept = event:FindFirstChild("ModcallAccepted")
function AcceptModcall(plr, userId)
local success, message, targetPlaceId, serverPlayerIn = service:GetPlayerPlaceInstanceAsync(userId)
service:TeleportToPlaceInstance(targetPlaceId, serverPlayerIn, plr)
end
event_accept.OnServerInvoke = AcceptModcall
Did you configure the code as directed? Print out both targetPlaceId and serverPlayerIn, check your console and see what you receive. It might be dropping the wrong returns.
@REALINONOOBYT You already suggested that and it won’t exactly work. Hard-coding PlaceIds isn’t scalable for a system reliant on them either.
I made a mistake and corrected the code, recopy what is in my code block. I accidentally copied the entire content of the thread page and posted it in my block instead of the code alone, so I ended up missing a piece.
local TeleportService = game:GetService("TeleportService")
local gameID = 00000000000
function onTouched(Hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:Connect(onTouched)
You keep suggesting the same things that deviate from the thread and don’t really answer the question. This doesn’t help.
Not only are you hard-coding IDs again which is not scalable for a mod call system, but this is a UI, not a teleport pad. This is also a teleport to another place, while OP is trying to teleport to a certain server in a place.
I feel like this should be a simple fix but the thread is starting to get slightly bloated. Mind printing the return values and this time, showing me your output?
local event_accept = event:FindFirstChild("ModcallAccepted")
function AcceptModcall(plr, userId)
local a, b, targetPlaceId, serverPlayerIn = service:GetPlayerPlaceInstanceAsync(userId)
print(a, b, targetPlaceId, serverPlayerIn)
service:TeleportToPlaceInstance(targetPlaceId, serverPlayerIn, plr)
end
Prints are a “form of debugging” (they really aren’t) that help you locate a source of error based on what the console reads from a print. For this case, I’d like to see what’s being returned from the call since apparently the place or the instance don’t exist.