Need help with triggering proximityprompt

What do you want to achieve?
i want the player to be able to chose between door 2.1 or door 2.2 and keep progressing trough the dungeon

  1. What is the issue?
    when i trigger the proximity prompt nothing happens, the door dosen’t open and the enemies don’t spawn

  2. What solutions have you tried so far?
    i tried reading trough the roblox documentation, but didin’t find anything, tried rewriting it in multiple ways wich didin’t work and asking chatgtp.

– This is the script
local RS = game:GetService(“ReplicatedStorage”)
local players = game:GetService(“Players”)
local plrs = players:GetPlayers()

local enemyFolder = RS:WaitForChild(“Enemies”)
local spawnsFolder = game.Workspace:WaitForChild(“Map”).Spawns
local SpawnedFolder = game.Workspace:WaitForChild(“SpawnedEnemies”)
local doorsFolder = spawnsFolder.Parent:WaitForChild(“Doors”)

local function randomEnemy()
local enemies = enemyFolder:GetChildren()
return enemies[math.random(1, #enemies)]
end

local function openDoor(roomNumber)
local door = doorsFolder:FindFirstChild(roomNumber)

if door then
	door.CanCollide = false
	door.Transparency = 1
end

if roomNumber == 2 then
	local door1Proximity = doorsFolder:FindFirstChild("2.1"):WaitForChild("ProximityPrompt")
	local door2Proximity = doorsFolder:FindFirstChild("2.2"):WaitForChild("ProximityPrompt")
	
	if door2Proximity and door1Proximity then
		if door1Proximity.Triggered then
			roomNumber += 0.1
			door2Proximity:Destroy()
			door1Proximity.Parent.CanCollide = false
			door1Proximity.Parent.Transparency = 1
			
		end
		
		if door2Proximity.Triggered then
			roomNumber += 0.2
			door1Proximity:Destroy()
			door2Proximity.Parent.CanCollide = false
			door2Proximity.Parent.Transparency = 1
		end
	else
		return
	end
	
end

end

local function spawnEnemies(roomNumber)
local spawns = spawnsFolder:GetChildren(roomNumber)

if not spawns then return end

for _, spawn in ipairs(spawns) do
	local enemy = randomEnemy():Clone()
	enemy.Parent = SpawnedFolder
	enemy:SetPrimaryPartCFrame(spawn.CFrame)
	enemy.Name = roomNumber
	enemy.Humanoid.Died:Connect(function()
		enemy:Destroy()
	end)
end

task.wait()

if SpawnedFolder:GetChildren(roomNumber) == nil then
	openDoor(roomNumber + 1)
end

end

players.PlayerAdded:Connect(function(player)
local room = 1
openDoor(room)
spawnEnemies(room)
end)

my main theory is a syntax error or something small like that, but im really not sure

The correct way to trigger a ProximityPrompt is:

proximityprompt.Triggered:Connect(function(playerWhoTriggered: Player): ()
	-- Trigger here
end)

thank you so much, this fixed it