Teleportation Error

I am making an elevator which teleports you at the end of the timer. Every time the timer ends, the game claims that the reserved server is restricted. I am trying to make a private server that only the people in the elevator can teleport to.

Here is the teleport module:

-- Services
local TeleportationService = game:GetService("TeleportService")

-- Variables
local TeleportationModule = {}

-- Main teleportation function
function TeleportationModule.Teleport(players)
	if typeof(players) == "table" and #players > 0 then
		-- Create a reserved server
		local success, reservedServerCode = pcall(function()
			return TeleportationService:ReserveServer(101052018455663)
		end)

		if success then
			-- Attempt to teleport players to the reserved server
			local teleportSuccess, errorMessage = pcall(function()
				TeleportationService:TeleportToPrivateServer(
					101052018455663, -- Place ID
					reservedServerCode, -- Reserved server code
					players -- List of Player objects
				)
			end)

			if not teleportSuccess then
				warn("Teleportation failed: " .. errorMessage)
			end
		else
			warn("Failed to create reserved server: " .. reservedServerCode)
		end
	else
		warn("No valid players to teleport!")
	end
end

-- Returns the module
return TeleportationModule

Here is the link to the game: Space Gaem

Thank you, all help is appreciated.
:slightly_smiling_face:

2 Likes

is this script try to tp players to other game or place inside game or a server ? if it trys tp to other game then that game go to file publish as and select the game and make new place and try replace id

The script is trying to teleport the player to a place inside the game.

Try using teleport async instead of teleport to private server as the latter shouldn’t be used for new work. If that doesn’t work then refer to this topic