GetFriendsOnline doesn't return a proper GameId (JobId) for me to teleport the player with

Hello!

So recently, I was coding a GUI that shows all of the Player’s friends which are online, and if their friends are playing my game, they will have an option to join their server, if they aren’t playing my game, or if they are just online, the player viewing that gui would have an option to invite them to my game!

But, I ran into a problem, on the wiki page, Player | Roblox Creator Documentation, under “GameId” it says that it returns a string JobId, however, when I tried it out, instead of giving me the player’s JobId, it gives me some other Int. (Instead of giving me something like this ‘00000000-0000-0000-0000-000000000000’ it gives me something like this ‘000000000’)

And there is the problem, since I can’t get the proper JobId of the Friend’s game-server, I can’t properly teleport the player. Even when I try to teleport the player with that GameId, It just gives me the teleport message. (‘Teleport failed because this game is restricted. (Unauthorized) Error Code: 773’)

What I tried.

I tried everything, from setting up a RemoteEvent, so the Teleportation could be done Server-sided, to trying other tweaks and tricks, but everything returned ‘Teleport failed because this game is restricted. (Unauthorized) Error Code: 773’. (I turned on third party teleports on my place, and yes, I am trying to teleport to a game that is in the same universe as the starter place.)

Everything is in a Local Script.
Here are some snippets of my code. (Some code wont be shown since it is mostly visual stuff.)

-- This function will be called when a certain button is pressed.
local function searchForFriends()
	local player = game:GetService("Players").LocalPlayer 
	local friendsOnline = player:GetFriendsOnline(11) 
	
	local FriendBarTemplate = script.Parent.FriendBarTemplate.FriendOnline
	
	script.Parent.FriendsMainFrame.NobodyOnline.Visible = true
	
	for index,friend in pairs(friendsOnline) do
		
		local canTeleportToGame = false
		local newFriendFrame = FriendBarTemplate:Clone()
		newFriendFrame.Parent = script.Parent.FriendsMainFrame.FriendsFrame
		newFriendFrame.Username.Text = friend.UserName
		newFriendFrame.UserHeadshot.Image = "rbxthumb://type=AvatarHeadShot&id="..friend.VisitorId.."&w=100&h=100"
		script.Parent.FriendsMainFrame.NobodyOnline.Visible = false
		print(friend.GameId, friend.UserName)
		
		
		if friend.LocationType == 0 or friend.LocationType == 2 then -- Website, or mobile site. 
		--(No code shown because it is working like it should.)
					
		elseif friend.LocationType == 3 or friend.LocationType == 6 then -- Studio
		--(No code shown because it is working like it should.)
	
		elseif friend.LocationType == 4 or friend.LoactionType == 1 then -- InGame (PC Client) or Mobile Client

			--(There is more code here, but its only for visual stuff. (Button colors, button text...))
			
			for index, value in ipairs(AcceptedGameIds) do -- AcceptedGameIds is a table containing gameIds. This basically makes it so players can't join friends who are playing other games.
				if friend.PlaceId == value then
					canTeleportToGame = true
				end
			end

			if canTeleportToGame == true then
				-- There was code here, but it was only for changing visual stuff.
				BtnJoinGame(newFriendFrame, friend.PlaceId, friend.GameId, friend.UserName, friend.UserId)
			else
				BtnInvite(newFriendFrame)
			end

		elseif friend.LocationType == 5 then -- XBox
			--(No code shown because it is working like it should.)
		end
		newFriendFrame.Visible = true
		
	end
end
-- These are the main functions, which do all the work. (Visual stuff not included.)
local function BtnInvite(frame)
	frame.InteractButton.MouseButton1Click:Connect(function()
		--(There is more code here, but its only for visual stuff. Tweening,...)
		SocialService:PromptGameInvite(Player)
		
		SocialService.GameInvitePromptClosed:Connect(function()
			--(There is more code here, but its only for visual stuff. Tweening,...)
		end)
		
	end)
end

local function BtnJoinGame(frame, PlaceId, GameId, FollowingPlayer, FollowingPlayerId)
	frame.InteractButton.MouseButton1Click:Connect(function()
		--(There is more code here, but its only for visual stuff. Tweening,...)
		TeleportService:TeleportToPlaceInstance(PlaceId, GameId, Player, nil, nil, script.Parent.Parent.TeleportGUI)
		-- PlaceId, GameId (JobId), Player (Not needed if in a local script.) spawnName, teleportData, customLoadingScreen.
		
	end)
end

Sorry if the code is messy, I didn’t really optimize it as much as possible, and I didn’t format it since when I write code, I firstly code the functionality, and when I get the expected result, then I optimize it and format it so it looks good and readable… And on top of that, I also cut a lot of the code since most of the code is just visual stuff. (I left out the most important code.)
So, is this even possible, I know that this worked like 3-4 months ago, since this is mostly just recycled code from my past game, in which, everything worked perfectly 3-4 months ago.

5 Likes

I’m having the same problem too. The Roblox documentation for GetFriendsOnline says the table will include “gameId” which is described as “The DataModel.JobId of the friend’s last location.”

JobIds are really long crazy guid, but I’m only getting a shorter in64 like you said.
What number is gameId right now? The documentation doesn’t tell you.

I think calling GetPlayerPlaceInstanceAsync should get me the data. But this is a big oversight.

2 Likes