Hello, I am having this issue in my game using a teleport method from the main game to a specific place connected to the game. I am getting the “attempted to teleport to a place” that is restricted error. I have tried enabling everything in the game settings security tab in both of the places, the issue still occurs. I will post the script we are using.
local TweenService = game:GetService("TweenService")
local TeleportService = game:GetService("TeleportService")
local safeTeleport = require(script:WaitForChild("SafeTeleport"))
local lobbies = workspace:WaitForChild("Lobbies")
for i, lobby in pairs(lobbies:GetChildren()) do
local playersInLobby = {}
local seats = lobby:WaitForChild("Van"):WaitForChild("Seats")
local hitbox = lobby:WaitForChild("Join"):WaitForChild("Hitbox")
local display = hitbox:WaitForChild("Display")
local playerCount = display:WaitForChild("PlayerCount")
local timer = display:WaitForChild("Timer")
timer.Text = ""
playerCount.Text = #playersInLobby .. "/" .. #seats:GetChildren() .. " Players"
hitbox.Touched:Connect(function(otherPart)
local char = otherPart.Parent
local plr = Players:GetPlayerFromCharacter(char)
if plr and not table.find(playersInLobby, plr) then
local seat = seats:FindFirstChild(1 + #playersInLobby)
local gui = plr.PlayerGui.MainGui
table.insert(playersInLobby, plr)
char.HumanoidRootPart.Anchored = true
char.Humanoid.WalkSpeed = 0
char.Humanoid.JumpPower = 0
char.Humanoid.PlatformStand = true
char.PrimaryPart.CFrame = seat.CFrame
gui.ExitLobby.Visible = true
playerCount.Text = #playersInLobby .. "/" .. #seats:GetChildren() .. " Players"
local function onPlayerLeave()
local pos = 0
for i, newPlr in ipairs(playersInLobby) do
if newPlr == plr then
pos = i
end
end
for i, newPlr in ipairs(playersInLobby) do
if i > pos then
local newSeat = seats:FindFirstChild(i - 1)
newPlr.Character.PrimaryPart.CFrame = newSeat.CFrame
end
end
table.remove(playersInLobby, pos)
playerCount.Text = #playersInLobby .. "/" .. #seats:GetChildren() .. " Players"
end
plr:GetPropertyChangedSignal("Parent"):Connect(onPlayerLeave)
gui.ExitLobby.MouseButton1Click:Connect(function()
gui.ExitLobby.Visible = false
gui.Timer.Visible = false
char.PrimaryPart.Anchored = false
char.Humanoid.JumpPower = 50
char.Humanoid.WalkSpeed = 16
char.Humanoid.PlatformStand = false
plr.Character.HumanoidRootPart.CFrame = lobby:WaitForChild("Join"):WaitForChild("Exit").CFrame
onPlayerLeave()
end)
if #playersInLobby == 1 then
timer.Text = "5s"
for i, newPlr in pairs(playersInLobby) do
local gui = newPlr.PlayerGui.MainGui
gui.Timer.Text = "5s"
gui.Timer.Visible = true
end
for i = 1, 5 do
task.wait(1)
if #playersInLobby < 1 then
timer.Text = ""
break
end
for e, newPlr in pairs(playersInLobby) do
local gui = newPlr.PlayerGui.MainGui
gui.Timer.Text = 5 - i .. "s"
end
timer.Text = 5 - i .. "s"
end
for i, newPlr in ipairs(playersInLobby) do
local gui = newPlr.PlayerGui.MainGui
local seat = seats:GetChildren()[i]
gui.ExitLobby.Visible = false
gui.Timer.Visible = false
local weld = Instance.new("WeldConstraint", seat)
weld.Part0 = seat
weld.Part1 = newPlr.Character.PrimaryPart
newPlr.Character.Humanoid.WalkSpeed = 0
newPlr.Character.Humanoid.JumpPower = 0
newPlr.Character.PrimaryPart.Anchored = false
end
for i, part in pairs(lobby:WaitForChild("Van"):GetDescendants()) do
if part ~= lobby.Van.PrimaryPart then
if part:IsA("BasePart") then
local weld = Instance.new("WeldConstraint", lobby.Van.PrimaryPart)
weld.Part0 = lobby.Van.PrimaryPart
weld.Part1 = part
part.Anchored = false
end
end
end
TweenService:Create(lobby.Van.PrimaryPart, TweenInfo.new(2.5, Enum.EasingStyle.Quad, Enum.EasingDirection.In), {CFrame = lobby.StopAcceleration.CFrame}):Play()
delay(2.5, function()
local server = TeleportService:ReserveServer(13933860205)
local options = Instance.new("TeleportOptions")
options.ReservedServerAccessCode = server
for i, newPlr in pairs(playersInLobby) do
local gui = newPlr.PlayerGui.MainGui
gui.BlackScreen.BackgroundTransparency = 1
gui.BlackScreen.Visible = true
TweenService:Create(gui.BlackScreen, TweenInfo.new(6, Enum.EasingStyle.Linear), {BackgroundTransparency = 0}):Play()
delay(6, function()
safeTeleport(13937594482, {newPlr}, options)
end)
end
TweenService:Create(lobby.Van.PrimaryPart, TweenInfo.new(7, Enum.EasingStyle.Linear), {CFrame = lobby.GoTo.CFrame}):Play()
end)
end
end
end)
end```