So basically, how can I use GetPlayerPlaceInstanceAsync to find what server they are in using their player ID?
Thank you.
So basically, how can I use GetPlayerPlaceInstanceAsync to find what server they are in using their player ID?
Thank you.
I don’t understand what your asking. Maybe it’s just me reading this wrong?
So basically, using GetPlayerPlaceInstanceAsync, I need to know how to find what server their in and TP to it.
This is what I need help with,
TeleportService:TeleportToPlaceInstance(placeId, jobId, player)
placeId: needs to be the server the player is in.
jobId: IDK!!!
player: Already have that.
Call that method with the player’s UserId.
local isInThisServer,error,placeID,jobID = TeleportService:GetPlayerPlaceInstanceAsync(TargetPlayerUserId)
if not isInThisServer then
TeleportService:TeleportToPlaceInstance(placeID,jobID,Player)
end
Keep in mind you should wrap the Async function in a pcall because sometimes it will error.
The Async function returns a tuple, which is the four variables we declare when we call it. The fourth is the jobID, which you can think of as the ID for a server. You take that and plug it into your teleport, and there you go.
Would this properly work?
local PlrID = script.Parent.PlayerUserID
local isInThisServer,error,placeID,jobID = TPS:GetPlayerPlaceInstanceAsync(PlrID.Value)
if not isInThisServer then
TPS:TeleportToPlaceInstance(placeID,jobID,game.Players.LocalPlayer)
end
No, you can only call GetPlayerPlaceInstanceAsync on the server. This is because it’s a call to the Roblox API and only the server can do that. This is also why it can sometimes fail.
You would need to send a remote event to the server, where you’d tell the server the target UserID you want to teleport to. The server would then run this function, except you’d swap game.Players.LocalPlayer with the player who fired the event.
alrighty, thank you so much!!!
Now its saying, Unable to cast string to a int64
any ideas?
This is the current code for the Script,
local TS = game:GetService(“TeleportService”)
script.Parent.OnServerEvent:Connect(function(Plr, PlayerTP)
local isInThisServer,error,placeID,jobID = TS:GetPlayerPlaceInstanceAsync(PlayerTP)
if not isInThisServer then
TS:TeleportToPlaceInstance(placeID,jobID,Plr)
end
end)
EDIT: PlayerTP returns the player to TP to’s ID.
Is PlayerTP a string? GetPlayerPlaceInstanceAsync wants a UserId, which must be supplied as an Integer.
This is what im giving the remote event, (path is the path to the value.)
local Numbers = Path.Text
try
local Numbers = tonumber(Path.Text)