I want to use Player:GetFriendsOnline() so that the player can teleport to a friend’s game if any of their friends are playing a game, but it does not work please help
Local script:
for i,v in pairs(game.Players.LocalPlayer:GetFriendsOnline(200)) do
if v.GameId ~= nil then
game:GetService("TeleportService"):TeleportToPlaceInstance(v.PlaceId, v.GameId, game.Players.LocalPlayer)
break
end
end
And v.GameId is just a bunch of numbers like 525382208 and I think thats whats supposed to be passed as the job id when i’m doing TeleportToPlaceInstance()
I’m getting the error that says “Teleport failed because The place is restricted” but I know its not restricted because i can join that person perfectly fine when I do it from the roblox site
If your friend is in a separate place apart from the starting place, you’re not able to join them that way cause they’re in a different place which results in that error
Could you try this?
for i,v in pairs(game.Players.LocalPlayer:GetFriendsOnline(200)) do
if v.GameId ~= nil then
game:GetService("TeleportService"):Teleport(v.GameId, game.Players.LocalPlayer)
break
end
end
I tried that and it took me to a completely different game ################### - Roblox this one apparently, which is the same game id as the one in the table I posted above
I also tried to do a teleport to a friend’s game that has only the starting place and it gives me the same error
Hm, try this? If that doesn’t work, try doing v.PlaceId for teleporting again
for i,v in pairs(game.Players.LocalPlayer:GetFriendsOnline(200)) do
if v.GameId ~= nil and v.IsOnline == true then
game:GetService("TeleportService"):Teleport(v.GameId, game.Players.LocalPlayer)
break
end
end
local player = game:GetService("Players").LocalPlayer
for _, v in ipairs(player:GetFriendsOnline(200)) do
if not v.IsOnline then continue end
if not v.PlaceId then continue end
game:GetService("TeleportService"):Teleport(v.PlaceId, player)
break
end
Also make sure that the “Allow third party teleports” is enabled in the place to which you are trying to teleport the player to.
local tpServ = game:GetService("TeleportService")
for i,v in pairs(game.Players.LocalPlayer:GetFriendsOnline(200)) do
if v.GameId ~= nil then
local instance,_,placeId,jobId
local success, result = pcall(function()
instance,_,placeId,jobId = tpServ:GetPlayerPlaceInstanceAsync(v.VisitorId)
end)
if success then
tpServ:TeleportToPlaceInstance(placeid, jobid, game.Players.LocalPlayer)
break
end
end
end
I did some research and saw about GetPlayerPlaceInstanceAsync, which returns 4 things, if the player is in an instance, an error if any, the placeid of where they are, and the jobid/instanceid, and its purpose is exactly what you’re wanting, to teleport to someone
I’d assume that he would enable “Third Party Teleports”, since he was able to teleport to a place but not to his friend’s game
@mymommakesbathbombs4
Overall, I don’t believe it’s possible to join a friend if they are not in the starting place from where they first join the game from; otherwise you just join the starting place that the PlaceId gives you
So TeleportToPlaceInstance requires a JobId as its second parameter, which looks like this: "21b1653d-ffcb-48f5-a0fa-2e25cac8375a"
However the “GameId” that comes from GetFriendsOnline doesnt return the JobId, but instead the universe ID of the game, although on the DevHub page it says that Player | Roblox Creator Documentation returns the JobId as GameId