TeleportAsync only teleports one player, and then refuses to teleport any more players

Before starting, I want to say my Experience is public and the places inside of it are also public. I have gone in and used Publish As in order to republish each individual place to where it needs to be, and have extensively tested to make sure each place is public. This is NOT the problem, please do not suggest setting the Place/Experience as Public.

I am using TeleportAsync in order to teleport a single player or multiple players into a new, reserved place. For some reason when teleporting multiple players, it will teleport the first player fine and then error out for the second player. The error I am getting is: “Teleport failed because Unable to join Game 512 (Unauthorized)”. The 3 digits after Game is sometimes different.

Every single question I’ve come across from teleportAsync bugging out is people forgetting to set their place to public, or some other issue that is easily resolved. That is NOT the issue I am having.

Multiplayer Teleport Code:

ReplicatedStorage.MultiplayerRemoteEvent.OnServerEvent:Connect(function(player, playerRating)
	if MatchmakingQueues:FindFirstChild(player.Name) then return end
	local HasFoundMatch = nil;
	
	for i, playersInQueue in pairs(MatchmakingQueues:GetChildren()) do
		if math.abs(playersInQueue.Rating.Value - playerRating) <= 100 or math.abs(playerRating - playersInQueue.Rating.Value) <= 100 then
			HasFoundMatch = playersInQueue.Value;
			playersInQueue:Destroy();
		end
	end
	
	if HasFoundMatch ~= nil then
		local playersToTeleport = {HasFoundMatch, player};
		
		ReplicatedStorage.FoundMatchEvent:FireClient(player, HasFoundMatch);
		ReplicatedStorage.FoundMatchEvent:FireClient(HasFoundMatch, player);
		
		local teleportOptions = Instance.new("TeleportOptions");

		teleportOptions.ShouldReserveServer = true;
		teleportOptions:SetTeleportData("Multiplayer");
		
		TeleportService:TeleportAsync(12332653401, playersToTeleport, teleportOptions);
		
	else
		--Code for creating a new party instance, works fine and doesn't matter in this context
	end
end)

When starting a single player session using

for i, v in pairs(MatchmakingQueues:GetChildren()) do
		v.TimeOut.Value -= 1;
		
		if v.TimeOut.Value <= 0 then
			ReplicatedStorage.FoundMatchEvent:FireClient(v.Value, nil);
			v:Destroy();
			
			local teleportOptions = Instance.new("TeleportOptions");

			teleportOptions.ShouldReserveServer = true;
			teleportOptions:SetTeleportData("Bots");

			TeleportService:TeleportAsync(12332653401, {v.Value}, teleportOptions);
			
		end
	end

It works, however after one player starts a single player game, no other player can teleport, and the console says the same error.

Any and all help is appreciated!

1 Like

I am pretty sure you can just teleport all the players at once using TeleportAsync (capped at 50 players per single call).

To do this, you just need to assign the playersToTeleport variable to an array (or table) containing the Player instances of all players you want to teleport. This will prevent the error Teleport failed because Unable to join Game 512 (UNauthorized) (i hope) :slight_smile:

Here’s an example I pulled and modified from here:

local Players = game:GetService("Players")
local TeleportService = game:GetService("TeleportService")

local TARGET_PLACE_ID = 1234 -- replace with your own place ID

local playersToTeleport = Players:GetPlayers() -- get all users in the experience

TeleportService:TeleportAsync(TARGET_PLACE_ID, playersToTeleport, teleportOptions)
2 Likes

I do not want to teleport every player, I only want to teleport the two players in the playersToTeleport array. This also does not help me, as I have tried teleporting every player by changing playersToTeleport to Players:GetPlayers(), and I still have the Teleport failed because Unable to join Game (Unauthorized) error. I have also attempted to use TeleportAsync in a different completely public game and experience, but it also did not work, throwing the same error.

Then you set the array of the two players you want to teleport as the variable. I am only showing you a piece of code you can adapt to suit your needs. I never said you wanted to teleport all the players in a server.

And you say any and all help is appreciated, however your attitude in your reply conflicts with this statement.

And doing some research, your experience is private


Obviously it won’t work if it’s private.

(I took the PlaceId in your TeleportAsync parameter and searched it up on roblox.com)

2 Likes

I apologize if my reply comes off as rude, I am quite agitated by this. I appreciate any help, even if it doesn’t particularly solve the issue. I have read through the roblox documentation a few times already. I privated the place after I stopped troubleshooting the issue, but during testing both the Experience and all places linked to it were public. Also, I have tested the same code but with the place IDs changed on a different Experience that I know for sure is public with the same error occuring.

Since my post, I have also attempted changing the code to Teleport(), TeleportToPrivateServer(), and TeleportPartyAsync() and all of these methods give me the same error, with only the first player in queue teleporting and the rest erroring out (Teleport failed because Unable to join Game 512 (Unauthorized)). If possible, I would love to find some documentation or explanation for this specific error, as I cannot find any other devforum posts about it or any documentation on the roblox reference website.

1 Like

I think TeleportPartyAsync should be used for arrays of players

TeleportAsync works with groups of players too

1 Like

It’s weird how there is practically nothing on the internet that documents this error :confused:

I have found the issue, apparently I was play testing with an outdated version of roblox. After asking a few friends to try it out, they were successfully able to play with no major changes. So silly! Thank you to everyone for your help in this situation.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.