Issues with teleporting to other player's game

I’m attempting to make a textbox in which fires a remote event to the script, gaining the target’s name and successfully teleporting them to the game. Unfortunately, it only functions as intended when I’m teleporting to someone that’s in the current placeId, but not to others. I’ve tried joining a friend of mine with the script that’s not in my placeId, but I received an error HTTP 404 TargetPlaceNotPartOfCurrentGame . What’s the issue here?

rep.SearchServer.OnServerEvent:Connect(function(plr, txt)
	local currentInstance, placeId, jobId
	local toConnect = plrs:GetUserIdFromNameAsync(txt)
	if toConnect then
		local success, failed = pcall(function()
			currentInstance, _, placeId, jobId = ts:GetPlayerPlaceInstanceAsync(toConnect)
		end)
		if success then
			ts:TeleportToPlaceInstance(placeId, jobId, plr)
		else
			warn(failed)
		end
	else
		print("no plr")
		return
	end
end)

The issue is stated in the error. Since the error says that TargetPlaceNotPartOfCurrentGame, it means that the place ID that you are providing is not part of the game. Make sure that the place is inside of the game that you are currently in.

Is this your only option to use a player’s username? There are other solutions such as Server Id.

Go to game settings (in studio) → Security → Enable “Allow Third Party Teleports” → Save