Why is this script not teleporting players?

Hi, I’m trying to create a private server thing where a player would click on Private Server → Private Server 1 or 2, then get teleported to a reserved server, but it isn’t working!
The issue I’m currently experiencing is that the player would get the message “Attempted to Teleport to a place that is restricted”! Image:

I’ve looked on the developer hub and it didn’t really help.

Here’s the code:

local tpService = game:GetService("TeleportService")

game.ReplicatedStorage.TeleporttoPS1.OnServerEvent:Connect(function(plr)
	local success, fail = pcall(function()
		tpService:ReserveServer(9691965768, "ReservedServer1"..plr.UserId)
	end)
	if success then
		print("Successfully created reserved private server ID "..game.PlaceId, plr.UserId.."1! Teleporting player shortly...")
	else
		warn(fail)
	end
	
	wait(3)
	
	local tpSuccess, tpFail = pcall(function()
		tpService:TeleportToPrivateServer(9691965768, "ReservedServer1"..plr.UserId, {plr})
	end)
	
	if tpSuccess then
		print("Teleporting player...")
	else
		warn(tpFail)
	end
end)

game.ReplicatedStorage.TeleporttoPS2.OnServerEvent:Connect(function(plr)
	local success, fail = pcall(function()
		tpService:ReserveServer(9691977623, "ReservedServer2"..plr.UserId)
	end)
	if success then
		print("Successfully created reserved private server ID "..game.PlaceId, plr.UserId.."2! Teleporting player shortly...")
	else
		warn(fail)
	end

	wait(3)
	local tpSuccess, tpFail = pcall(function()
		tpService:TeleportToPrivateServer(9691977623, "ReservedServer2"..plr.UserId, {plr})
	end)

	if tpSuccess then
		print("Teleporting player...")
	else
		warn(tpFail)
	end
end)

Any help would be appreciated! I do have third party teleports enabled!

1 Like

TeleportService | Roblox Creator Documentation is the description from Roblox Creator Documentation

The older site (developer.roblox.com) has this description: Teleporting Between Places

Both give troubleshooting and failed teleport fixes.

1 Like

I will check it out, thank you in advance!

Thank you for the help! This solution worked for me.

1 Like