Is there anyway for my door to not bug open and close

Hi, Im trying to make my door not go up and down at the same time when someone walks through it.

Heres what it does https://streamable.com/caq3rn

The script is

local door = script.Parent:WaitForChild("Door")
local sensor1 = script.Parent:WaitForChild("Sensor1")
local sensor2 = script.Parent:WaitForChild("Sensor2")
local noise = door:FindFirstChild("Noise")

doorOpen = false

local tweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1.79, Enum.EasingStyle.Linear, Enum.EasingDirection.In,0,false,0)

local doorPos1 = {CFrame = CFrame.new(-68.683, 10.023, -53.5)}
local doorPos2 = {CFrame = CFrame.new(-68.683, 3.25, -53.5)}

local open = tweenService:Create(door,tweenInfo,doorPos1)
local close = tweenService:Create(door,tweenInfo,doorPos2)

sensor1.Touched:Connect(function()
	if doorOpen == false then
		open:Play()
		wait(3.3)
		doorOpen = true
		wait(3.3)
		close:Play()
	end
end)

sensor2.Touched:Connect(function()
	if doorOpen == true then
		open:Play()
		wait(3.3)
		doorOpen = false
		wait(3.3)
		close:Play()
	end
end)

If anyone can help I would appreciate it :slight_smile:

if doorOpen == false then
	open:Play()
	wait(3.3)
	doorOpen = true
	wait(3.3)
	close:Play()
end

try to set a dooropen when the if statement was passed. So it check once

what exactly is the bug? is it the door instantly closing after opening?

Well, Yes but its not instantly it takes a second or 2

It because you set a cooldown value after a tween

It’s because you made the script wait 3.3 seconds before playing the closing tween, make the value largest if you want it to wait longer before closing or remove the Wait() to make the door close straight after