Attempted to teleport to a place that is restricted

Attempted to teleport to a place that is restricted
So I’m working on a horror game, and I’m at the moment working on building a lobby similar to the one Doors has. The teleport system works as every other story game, by teleporting everyone inside the TeleportPoint to another place.

The system works perfectly but whenever it sends a player to another place it says Attempted to teleport to a place that is restricted

How would I fix this?


local TransitionEvent = game.ReplicatedStorage.TransitionEvent
local TeleportService = game:GetService("TeleportService")
local TeleportID = 13937910964

local Players = {}
local IsTeleporting = false
local TeleportPoint = script.Parent.TeleportPoint
local PlayersAllowed = script.Parent.PlayersAllowed

local Gate = script.Parent.Gate
local Timer

local GUI = Gate.SurfaceGui
local PlayerNumber = GUI:WaitForChild("PlayerNumber")
local PlayerNumberShadow = GUI:WaitForChild("PlayerNumber"):WaitForChild("PlayerNumber1")
local TimeNumber = GUI:WaitForChild("TimeNumber")
local TimeNumberShadow = GUI:WaitForChild("TimeNumber"):WaitForChild("TimeNumber1")
local ExitEvent = game.ReplicatedStorage.ExitEvent

game.Players.RespawnTime = 0

function Refresh()
	PlayerNumber.Text = #Players.."/4"
	PlayerNumberShadow.Text = #Players.."/4"
end

local function RemoveFromList(Char)
	for i = 1,#Players do
		if Players[i] == Char.Name then
			table.remove(Players, i)
			Char.Humanoid.JumpPower = 50
			Refresh()
		end
	end
end


local function Teleport()
	if #Players > 0 then
		local TeleportPlayers = {}

		for i = 1, #Players do
			if game.Players:FindFirstChild(Players[i]) then
				table.insert(TeleportPlayers, game.Players:FindFirstChild(Players[i]))
				TransitionEvent:FireClient(game.Players:FindFirstChild(Players[i]))
			else
				table.remove(Players, i)
			end
		end

		local Code = TeleportService:ReserveServer(TeleportID)
		
		IsTeleporting = true
		TeleportService:TeleportToPrivateServer(TeleportID, Code, TeleportPlayers)
		
		repeat wait() until #Players <= 0
		
		IsTeleporting = false
	end
end


Gate.Touched:Connect(function(Hit)
	if Hit and Hit.Parent:FindFirstChild("Humanoid") then
		if IsTeleporting == false then
			local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
			local Character = Player.Character or Player.CharacterAdded:Wait()
			local InsideGate = false
			
			for i = 1, #Players do
				if Players[i] == Character.Name then
					InsideGate = true
				end
			end
			
			if InsideGate == false and #Players < PlayersAllowed.Value then
				table.insert(Players, Character.Name)
				Character:WaitForChild("HumanoidRootPart").CFrame = TeleportPoint.CFrame
				Character.Humanoid.JumpPower = 0
				Refresh()
				ExitEvent:FireClient(Player)
			end
			
			Player.CharacterRemoving:Connect(function(Char)
				RemoveFromList(Char)
			end)
			
		end	
	end
end)

ExitEvent.OnServerEvent:Connect(function(player)
	if player.Character then
		player.Character.Humanoid.Health = 0
		RemoveFromList(player.Character)
	end
end)

while wait() do
	if #Players > 0 then
		Timer = 30	
		for i = 1, Timer do
			if #Players > 0 then
			Timer = Timer - 1
			TimeNumber.Text = Timer
			TimeNumberShadow.Text = Timer
				wait(1)
			else
				TimeNumber.Text = ""
				TimeNumberShadow.Text = ""
				Timer = 30
			end
		end
		Teleport()
	else
		TimeNumber.Text = ""
		TimeNumberShadow.Text = ""
	end
end

Thanks for reading!

9 Likes

Make sure the place id, you are teleporting the players to is correct. I cannot really think of another issue

It is the correct place ID, the issue has not been resolved

Also, did you enable in the game settings → security → allow third party teleports? If not, this could be the issue

1 Like

I have no idea why this would help as the place is in the same game universe.

But to answer your question, yes I already tried enabling that and it did of course not have any impact on the issue.

I’m assuming this is possibly Code 773? If this is the case I know this issue has been raised on numerous occasion through the years so could likely be something messing up server sided. A concrete solution to this, from my knowledge, isn’t that clear as people have had different solutions.

You can try using TeleportAsync or manually updating your subplaces until they (suddenly?) can be teleported into - based on what I gathered from past topics.

Yes this is indeed code 773. What solutions could I possibly try?

I would definitely search through Devforum with the keyword “Error 773” as this stuff, like mentioned, has been raised a number of times. You can also try searching this on a browser as well for more information on the matter.

1 Like

Did you published the place where you want to teleport the players? And have you set it to public?

The main game is published, I didn’t know you could publish places. Where and how do I publish places?

Are you testing your game with multiple Roblox player clients? Seems to be a documented engine bug if so:

I’m not using TeleportAsync so this can’t be the case.

Open the place you want to teleport the players in, and do like you would publish a normal game on Roblox. So open “File” and select “Publish to Roblox” or “Publish to Roblox as”.

If you want to use “Publish to Roblox as” select the game you’re working on, and then select the place you want to publish as. Don’t do that with any other places than the one you want to publish, as it will overwrite all the datas of the place you’re trynna publish.

For instance, if you try to publish the place where you want to tp players at as your lobby, it’ll overwrite all your lobby data, and you’ll lose your work.

Tell me if it worked!

2 Likes

Are you still using multiple clients? The recorded bug is with TeleportAsync but it most likely extends to other methods as Roblox does not intend for multiple clients to be used at once outside of Studio.

Well for this method I’m basically converting my place to a game, and then I’ll have to enable third-party teleports as they are not in the same game universe then. I will try this method and tell you if it worked or not.

1 Like

Places that are part of a universe to my knowledge to not need to be published if they are already created?.. Thus being published by defenition. Perhaps you are referring to ensuring that a place is on the correct version?

I had the same issue when making a matchmaking system, then I published my places and it worked. So it might be the solution for him as well.

Yes, and that is still the case, as the place will react by listening to the main game. If you set the main game to private all the places that follow will be private as well.

The thing is when you made that matchmaking system I think you didn’t make a different place, I think you made a different game and then used third-party teleports to teleport the player into another one of your games.