Help with TeleportService

I have a big problem, i’m creating a elevator that after like 15 seconds teleports all players into a reserved server.
The problem is on the Teleport part. When i try to teleport gave me an error with

raiseTeleportInitFailedEvent: Teleport failed because This game is not published. (Unauthorized)

I published all the places, and everything. It doesn’t work.
I think is not the script.

Help me, please.

The Code:

local sendReserve = TeleportService:ReserveServer(code)
		teleporting = true
		local succ,err = pcall(function()
			TeleportService:TeleportToPrivateServer(code, sendReserve, playersTeleport)
		end)
		if succ and not err then
			repeat wait() until	#playersTeleport <= 0
			billboard.Main.Countdown.Text = "Ready..."
			teleporting = false
		elseif not succ and err then
			print("Teleport Failed: ", err)
		end

Did you publish the game in studio with this script?

Edit: Make sure you put the right code.

It’s a function i forgot to put all of the code sorry!

local function teleportToServer()
	if #usersTeleporting > 0 then
		billboard.Main.Countdown.Text = "Teleporting..."
		local playersTeleport = {}
		local teleportTime = 0
		for i = 1, #usersTeleporting do
			local player = Players:GetPlayerByUserId(usersTeleporting[i])
			if Players:FindFirstChild(player.Name) then
				table.insert(playersTeleport, player)
			else
				table.remove(usersTeleporting, getIndex(usersTeleporting, player.UserId))
			end
		end
		local sendReserve = TeleportService:ReserveServer(code)
		teleporting = true
		local succ,err = pcall(function()
			TeleportService:TeleportToPrivateServer(code, sendReserve, playersTeleport)
		end)
		if succ and not err then
			repeat wait() until	#playersTeleport <= 0
			billboard.Main.Countdown.Text = "Ready..."
			teleporting = false
		elseif not succ and err then
			print("Teleport Failed: ", err)
		end
	end
end

And yes is published

Show me the parameters passed to the function. Also, is ‘code’ the placeID?

code is the placeId yes.

there is no parameters passed to the function. I tested all and worked. The player get detected and everything. Trust me.

I get only an error of teleporting, like if the place is not published (but it is)

Did you try this in the roblox game and not in studio?

Tryed in the Roblox Game, not in Roblox Studio because it doesn’t work :slight_smile:

Both games are under your profile correct? and not under some group/vise versa

My game is inside a group, the place i need to access is inside the first place like this.

Lobby (id) Under the Lobby there is Game - Solo (id)