Hi! So my teleportation script keeps erroring saying it cannot cast string into int64, and I don’t understand what is wrong. Can anybody help me?
script.Parent.OnServerEvent:Connect(function(plr,sp)
local success, errorMessage, placeId, jobId = pcall(function()
return game:GetService("TeleportService"):GetPlayerPlaceInstanceAsync(sp)
end)
if success then
-- Teleport player
game:GetService("TeleportService"):TeleportToPlaceInstance(placeId, jobId, plr) --Error is located here.
else
warn(errorMessage)
end
end)
Your pcall set errorMessage into a variable instead. Print out all the variables to see exactly why. There is no error message since all of its variables are returned in order starting from the second and so on.
An arbitrary test on pcall reveals:
local a, b, c = pcall(function()
return "a", "cee", "LOL"
end)
print(a, b, c) -- true, "a", "cee"
Assuming that value comes from a GUI input you should consider running it through tonumber(sp) on the server before sending the TeleportService teleport request.
This most likely isn’t the source of your error as Operatik explained.