Teleporting a table of players to a private server

Is that the correct placeId for the ReservedServer?

yes I even copied the id of it and re pasted it just in case.

Any errors in the output??

chars

other then the HTTP 403 forbidden, no.

Are you testing this in roblox and not in studios?

I did both, and yes it didnt teleport me while using roblox.

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

local rooms = {
	Room1 = {
		players={},
		code=0
	},
	Room2 = {
		players={},
		code=0
	},
	Room3 = {
		players={},
		code=0
	}
}

game.ReplicatedStorage.StartRoom.OnServerEvent:Connect(function(player, roomName)
	local room = rooms[roomName]
	print(roomName.players, #room.players)
	for _, plr in pairs(room.players) do
		print(plr)
	end
	if #room.players > 0 then
		local playerList = room.players
		local placeId = TeleportService:ReserveServer(game.PlaceId)
		local success, result = pcall(function()
			print(playerList)
			return TeleportService:TeleportToPrivateServer(game.PlaceId, placeId, playerList)
		end)
		
		print(success, result)
		for _, plr in pairs(playerList) do
			print(plr)
		end

		if success then
			local jobId = result
			print("Players teleported to "..jobId)
		else
			warn(result)
		end
	end
end)

game.ReplicatedStorage.JoinRoom.OnServerEvent:Connect(function(player,roomName)
	local newPlayers = {}
	for _, v in ipairs(rooms[roomName].players) do
		table.insert(newPlayers, v)
	end
	table.insert(newPlayers, player)
	print(newPlayers)
	rooms[roomName].players = newPlayers
	print(player.Name.." joined "..roomName..".")
end)

This is the script from before, I think it looks like you got teleported to the same server even though you didn’t, its just that it looks the same.

yes but I didnt even add anything in the new place yet?

Yes, I will be able to get back to my computer in about an hour, where I will be able to solve this once and for all (hopefully)

Yes I seriously do appreciate it bro, I noticed you had a youtube, ill go follow it and maybe your tutorials will help me with other things

1 Like

Alrighty, so I finally solved the problem. This is what your ServerScript should look like:

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

local rooms = {
	Room1 = {
		players={},
		code=0
	},
	Room2 = {
		players={},
		code=0
	},
	Room3 = {
		players={},
		code=0
	}
}

game.ReplicatedStorage.StartRoom.OnServerEvent:Connect(function(player, roomName)
	local room = rooms[roomName]
	if #room.players > 0 then
		local playerList = room.players
		local placeId = TeleportService:ReserveServer(9500853800)
		local success, result = pcall(function()
			return TeleportService:TeleportToPrivateServer(9500853800, placeId, playerList)
		end)

		if success then
			local jobId = result
		else
			warn(result)
		end
	end
end)

game.ReplicatedStorage.JoinRoom.OnServerEvent:Connect(function(player,roomName)
	local newPlayers = {}
	for _, v in ipairs(rooms[roomName].players) do
		table.insert(newPlayers, v)
	end
	table.insert(newPlayers, player)
	rooms[roomName].players = newPlayers
end)

Note I removed all the prints as well.