Teleporting to Reserve Server not working

I made a matchmaking system for my game and finding the players works as well as the messaging service request. Except, the actual teleporting doesn’t work as I get this error “Teleport failed because Access code for reversed server us bit valid.” I tried using TeleportToPrivateServer() but it does not seems to work. I also checked the access code and it matches the one from subscribe async to where it was created and it is the same.

Code for just the important part (Note some code is not included but is not involved in the error):

msgServ:SubscribeAsync("TeleportPlayer",function(msg)
	print("Received tp request",msg.Data.plrId,game.Players:GetNameFromUserIdAsync(msg.Data.plrId))
	for _,v in pairs(game.Players:GetPlayers()) do
		if v.UserId == tonumber(msg.Data.plrId) then
			game.ReplicatedStorage.Events.SendPlrMsg:FireClient(v,"Match found! Teleporting to match...")
			local tpOptions = Instance.new("TeleportOptions")
			tpOptions.ReservedServerAccessCode = msg.Data.code
			tpOptions:SetTeleportData("GrassyIsland|Surival|rbxassetid://16914577079")
			tpServ:TeleportAsync(9045317863,{v}, tpOptions)
		end
	end	
end)

while wait(math.random(20,60)/100) do
	local _queue = {}

	local success, __queue, _id = pcall(function()
		return queue:ReadAsync(1,false,2)
	end)

	if success and __queue then
		for _,v in pairs(__queue) do
			table.insert(_queue,v)
			if #_queue == 1 then
				local success, id = tpServ:ReserveServer(9045317863)
				print("Created party id!", id)
				for _,v2 in pairs(_queue) do
					if success then 
						local replication = table.clone(_queue)
						table.remove(replication,table.find(replication,v2))
						msgServ:PublishAsync("TeleportPlayer",{plrId = v2,code = id,otherPlayers = replication})
						print("Send tp request to all lobbies",v2,game.Players:GetNameFromUserIdAsync(v2))
					end
					task.wait()
				end
				table.clear(_queue)
				queue:RemoveAsync(_id)
			end
		end
	elseif not success then
		warn("Error"..__queue)
	end
end 

Apparently it was because reserve server function was not in pcall function from the specifc variable initialization.

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