Needing Help with door system

  1. What do you want to achieve? A door system, though I am having an error.

  2. What is the issue? Only 1 door is able to open. When said door closes, another one is able too

  3. I looked on dev forum + youtube

-- @classMod DoorService
-- @author lumbergrim

-- Handles All Doors

local Players = game:GetService("Players")
local CS = game:GetService("CollectionService")
local TweenService = game:GetService("TweenService")
local RReplicated = game:GetService("ReplicatedStorage")
local Debounce = false

-- Door Var
local Sounds = RReplicated.doors.Sounds
local Doors = RReplicated.doors
local Success = Doors.success
local Failed = Doors.failed
local Lockdown = Doors.failed



local DoorsService = {}






for _,BlastDoor in pairs(workspace.Doors.BlastDoor:GetChildren()) do
	if BlastDoor:IsA("Model") then
		CS:AddTag(BlastDoor, "BlastDoor")
	end
end

local function BlastDoorFunction()
if CS:GetTagged("BlastDoor") then
	for _,Tags in pairs(CS:GetTagged("BlastDoor")) do
		Tags:FindFirstChild("Union").ProximityPrompt.Triggered:Connect(function(plr)
			local TweenInformation = TweenInfo.new(
				4,
				Enum.EasingStyle.Sine,
				Enum.EasingDirection.Out,
				0,
				true,
				0.5)
			if not Debounce then
				Debounce = true
				local tween = TweenService:Create(Tags.PrimaryPart, TweenInformation, {Position = Tags.Closed.Position})
				tween:Play()
				Sounds.BlastDoorOpen:Play()
				Success:FireClient(plr)
				wait(4)
				tween:Pause()
				wait(3)
				tween:Play()
				wait(4.4)
				Debounce = false 
			end
		end)
	end
end
end

local BlastDoor = CS:GetInstanceAddedSignal("BlastDoor")

BlastDoor:Connect(BlastDoorFunction())
	
return DoorsService	

What you are doing here is yielding. This stops the loop and it can’t continue with the other doors.

wait(4)
tween:Pause()
wait(3)
tween:Play()
wait(4.4)

So you should wrap this in task.spawn()

task.spawn(function()
    task.wait(4)
    tween:Pause()

    task.wait(3)
    tween:Play()

    task.wait(4.4)
    Debounce = false 
end)

Thank you, Also, How does task.spawn() change this? (Thanks for ur help it worked)

task.spawn() Spawns a new function on a separate thread. So the waiting is not done on the loop.

I see, thanks for your help!

(ignore ignore ignore ignore ignore)