Players not teleporting to Reserved place

Hello, I have issues with the teleporting of players to a place. I have a horror game and at the beginning players spawn at a lobby and together they can enter those rooms to be teleported to the main game, just like Doors. However I am still not getting teleported, the only error I get is HTTP 403 forbidden, however I have activated all the the settings I have to activate, like API, 3rd party teleportation, etc. I used ChatGPT, checked other topics but none of them helped. This is my script:

local TeleportService = game:GetService("TeleportService")
local part = game.Workspace.Teleport.Check  -- Change this to reference your actual teleportation part
local leavePart = game.Workspace.Left
local Timer = game.Workspace.Teleport.Teleport.SurfaceGui.Frame.Time.Value

local privateServerPlaceId = 4512185295  -- Change this to your private server Place ID

local playersInside = {}  -- Use a table to keep track of players inside the part

local TeleportOptions: TeleportOptions = Instance.new("TeleportOptions")
TeleportOptions.ShouldReserveServer = true

local function teleportPlayers()
    local playerList = {}

    for player, _ in pairs(playersInside) do
        table.insert(playerList, player)
    end

    TeleportService:TeleportAsync(privateServerPlaceId, playerList, TeleportOptions)
end

local function onTouched(otherPart)
	local character = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if character and not playersInside[character] then
		playersInside[character] = true
		print("Player added:", character.Name)
		wait(1)
	end
end

local function onTouchEnded(otherPart)
	local character = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if character and playersInside[character] then
		local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
		if humanoidRootPart then
			local playerPosition = humanoidRootPart.Position
			local partPosition = part.Position
			local partSize = part.Size

			if (playerPosition - partPosition).Magnitude > partSize.Magnitude / 2 then
				playersInside[character] = nil
				print("Player removed:", character.Name)
			end
		end
	end
end

local function onLeaveTouched(otherPart)
	local character = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if character and playersInside[character] then
		playersInside[character] = nil
		print("Player removed from Leave:", character.Name)
		wait(1)  -- Wait for 1 second before allowing re-entry
	end
end

part.Touched:Connect(onTouched)
leavePart.Touched:Connect(onLeaveTouched)

-- Connect the TouchEnded event for HumanoidRootPart within characters
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
		humanoidRootPart.Touched:Connect(onTouched)
		humanoidRootPart.TouchEnded:Connect(onTouchEnded)
	end)
end)

-- Continuously check the timer and teleport players when it's 0
while true do
	wait(1)
	if Timer.Value == 0 then
		teleportPlayers()
	end
end

Nevermind, I was coding the whole day yesterday and at some point my brain couldn’t process it anymore. I had the wrong local part location given.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.