TeleportToPrivateServer says "Attempted to teleport to a place that exists"

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I’m trying to use TeleportToPrivateServer. I need to use TeleportToPrivateServer because I need them to be private servers and I don’t want to use VIP servers.

  2. What is the issue? Include screenshots / videos if possible! When I try using it, everything works except when TeleportService trys to teleport. It has the error “Attempted to teleport to a place that doesn’t exist”. I know the private server exists because one of my friends are there as well! If any more clarification is needed lmk. I don’t need my script to be rewritten, I just don’t understand this problem.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes, I’ve looked around Developer Hub and such. I’ve tried replacing the system with TeleportToPlaceInstance and it’s worked fine, but when I try with privateserverid it doesn’t work. This is also between 2 places in a place universe.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Here is the code that teleports the player to the server, if you need any more lmk in the comments! This is in a group game if that helps too!

local function TeleportToServer(plr,id)
	local succ,err = pcall(function()
		warn("attempting to teleport "..plr.Name.." to "..MainPlaceId.." with reserved "..id..".")
	end)
	if not succ then warn("trying to do it anyway, but something went wrong? + "..err) end
	local succ, err = pcall(function()
		TeleportService:TeleportToPrivateServer(MainPlaceId,id,{plr})
	end)
	if not succ then warn("error message: "..err) end
	--TeleportService:TeleportToPlaceInstance(MainPlaceId,id,plr)
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

Do You have third party teleports enabled?

Why are trying to teleport the player two times by putting them in a table twice? Put it once and see if that fixes it.

Third party teleports are turned off, the places are in the same place universe so that shouldn’t matter.

I’ve tried both ways, I just forgot to put it back to just {plr}, sorry!

So far, I don’t see anything wrong with your script. Could you by chance show the entirety of the script that initiates the teleport?

This good?

local TeleportService = game:GetService("TeleportService")
local SDS = game:GetService("DataStoreService"):GetDataStore("ServerList") -- key is Servers_09

local MainPlaceId = 5622532370

local function GetServers()
	return SDS:GetAsync("Servers_09")
end

game.ReplicatedStorage.Remotes.GetServers.OnServerInvoke = GetServers

local function TeleportToServer(plr,id)
	local succ,err = pcall(function()
		warn("attempting to teleport "..plr.Name.." to "..MainPlaceId.." with reserved "..id..".")
	end)
	if not succ then warn("trying to do it anyway, but something went wrong? + "..err) end
	local succ, err = pcall(function()
		TeleportService:TeleportToPrivateServer(MainPlaceId,id,{plr,plr})
	end)
	if not succ then warn("error message: "..err) end
	--TeleportService:TeleportToPlaceInstance(MainPlaceId,id,plr)
end

game.ReplicatedStorage.Remotes.JoinServer.OnServerEvent:Connect(function(plr,id)
	TeleportToServer(plr,id)
end)

game.ReplicatedStorage.Remotes.JoinCodeServer.OnServerEvent:Connect(function(plr,code)
	local mastertable = SDS:GetAsync("Servers_09")
	
	if mastertable==nil then print("no servers") return end
	
	code = code:upper()
	
	for i,Table in pairs(mastertable) do
		if Table[2] == code then
			TeleportToServer(plr,Table[1])
			return
		end
	end
	
	warn(plr.Name.." tried joining "..code.." but couldn't find it!")
end)

require(game.ServerStorage.Logic.ServerManager):Start()

Dang, I’m stumped here. I’ll have another look at this tomorrow. And could you also show where this event is being called?

Have a good night! Here is the code that starts the event.

local JoinServer = game.ReplicatedStorage.Remotes.JoinServer
script.Parent.JOIN.MouseButton1Down:Connect(function()
	JoinServer:FireServer(script.Parent.Name)
end)

I should also provide some more information:
I can confirm that the private server id, place id, and player are all good. I’ve also tried using the private server id to teleport to the game manually through the F9 Console but it gave the same error. (I took the acutal private server id from the game thats supposed to be teleported to and tried the same thing, which didn’t work. I’ve seen elsewhere that group games break this, but I don’t want to move it out of the group.

Are you using the gameId or the placeId?

What do you mean? I used the placeid, then the reserved code, and then a table of the player.

Nevermind, I was thinking something different. Can you show me the logic where you are reserving the server and saving the private server code?

Well for making the server, i just use the console for now, to make sure this works. For the saving of it, when you join the server it sends a message through messagingservice (i know, i’ll improve on it later) to save it on the main server.

function SendServerWideMessage:Send()
	local success, message = pcall(function()
		MessagingService:PublishAsync(TOPIC,"add|"..game.PrivateServerId.."|"..game.ServerStorage.ServerCode.Value.."|"..game.ServerStorage.Deceptors.Value.."|"..game.ServerStorage.Host.Value.."|"..#game.Players:GetPlayers())
	end)
	if not success then
		warn("Messaging service hit the disco neigh because "..message.."!")
	end
end
local MessagingListener = {}

local MessagingService = game:GetService("MessagingService")
local TOPIC = "ServerList"

local Functions = {
	["add|"] = function(params)
		warn("add|"..params)
		
		params = string.split(params,"|")
		
		if #params==5 then
			print("yoo look count is working!!!")
			
			local Id = params[1]
			local Code = params[2]
			local ImpCount = params[3]
			local HostName = params[4]
			local Plrs = params[5]
			
			require(script.ServerCache):Add({Id,Code,{ImpCount,HostName,Plrs}})
		end
	end,
	["del|"] = function(id)
		warn("del|"..id)
		
		require(script.ServerCache):Remove(id)
	end,
	["addp|"] = function(id)
		warn("addp|"..id)
		
		require(script.ServerCache):NewPlayer(id)
	end,
	["delp|"] = function(id)
		warn("delp|"..id)
		
		require(script.ServerCache):RemovePlayer(id)
	end
}

local FunctionNames = {"add|","del|"}

function MessagingListener:StartListening()
	print("MessagingListener has starting listening!")
	MessagingService:SubscribeAsync(TOPIC,function(message)
		message = message.Data
		
		for _,name in pairs(FunctionNames) do
			if string.find(message,name) then
				Functions[name](string.split(message,name)[2])
				break
			end
		end
	end)
end
local ServerCache = {}

local SDS = game:GetService("DataStoreService"):GetDataStore("ServerList") -- key is Servers_09

local function FindTable(id)
	local mastertable = SDS:GetAsync("Servers_09")
	if mastertable==nil then print("no servers") return end
	
	for i,Table in pairs(mastertable) do
		if Table[1] == id then
			return i
		end
	end
	
	return nil
end

function ServerCache:RemovePlayer(id)
	local mastertable = SDS:GetAsync("Servers_09")
	if mastertable==nil then print("no servers") return end
	local Index = FindTable(id)
	local Table = mastertable[Index]
	
	if Table then
		Table[3][3] = Table[3][3] - 1
		print(Table[3][3])
		SDS:SetAsync("Servers_09",mastertable)
		
	end
end

function ServerCache:NewPlayer(id)
	local mastertable = SDS:GetAsync("Servers_09")
	if mastertable==nil then print("no servers") return end
	local Index = FindTable(id)
	local Table = mastertable[Index]
	
	if Table then
		Table[3][3] = Table[3][3] + 1
		print(Table[3][3])
		SDS:SetAsync("Servers_09",mastertable)
	end
end

function ServerCache:Remove(id)
	local mastertable = SDS:GetAsync("Servers_09")
	if mastertable==nil then print("no servers") return end
	local Index = FindTable(id)
	
	if Index then
		table.remove(mastertable,Index)
		SDS:SetAsync("Servers_09",mastertable)
	end
end

function ServerCache:Add(ServerTable)
	local mastertable = SDS:GetAsync("Servers_09")
	if mastertable==nil then mastertable = {} end
	
	warn(ServerTable[1].." has been added to the server cache bro!!!")
	if FindTable(ServerTable[1])==nil then
		table.insert(mastertable,ServerTable)
		SDS:SetAsync("Servers_09",mastertable)
	end
end

return ServerCache

I think I got it

for i,Table in pairs(mastertable) do
	if Table[2] == code then -- Checking 2nd position
		TeleportToServer(plr,Table[1]) -- Sending 1st position
		return
	end
end

Just change Table[1] to Table[2], as you’re comparing the codes with Table[2]

Table[1] is the privateserverid, Table[2] is a 5 character “code” comprised of 5 capital letters.

The if statement is checking a different remote event, which sends when a player tries to input a specific code. The super small remote event is when a player presses the join button.

If Table[2] is the code, you are calling the TeleportToServer function with the private server id (Table[1]) and putting that ID in the second argument of TeleportToPrivateServer. In the docs it says that the second argument should be the acess code.

The private server id is the access code, isn’t it? Table[2] is a 5 letter code made by randomizing letters.

My bad, you’re correct.

What does Table[1] print to?

Table[1] returns the private server id of the server.

Are you sure it’s actually the private server id? The teleport code looks fine, yet the code is invalid.