Major issues with keycard door

So my keycard door is having major issues… When you touch it with the card it will open kinda then it will stay open and you have to click it to close at which point everything starts gettin really weird… so here is my code if you think you can help

local Tween_Service = game:GetService("TweenService")

local Clearance = {
   ["Level - 0"] = true,
   ["Level - 1"] = true,
   ["Level - 2"] = true,
   ["Level - 3"] = true,
   ["Level - 4"] = true,
   ["Level - 5"] = true,
   ["O5 Keycard"] = true,
   ["Omni Keycard"] = true,
   ["Armory Access"] = true
}

local Door = script.Parent.Door.DoorMain
local KeyArea1 = script.Parent.KeycardReader1.KeycardReader
local KeyArea2 = script.Parent.KeycardReader2.KeycardReader

local Bool = true
local Cooldown = false

local TI = TweenInfo.new(
   1.5,
   Enum.EasingStyle.Linear,
   Enum.EasingDirection.In,
   0,
   false,
   0
)

local openCFrame = Door.CFrame * CFrame.new(4.1,0,0)
local closeCFrame = Door.CFrame * CFrame.new(-4.1,0,0)

local DoorClose = Tween_Service:Create(Door, TI, {CFrame = openCFrame})
local DoorOpen = Tween_Service:Create(Door, TI, {CFrame = closeCFrame})

local function OpenDoor()
   DoorOpen:Play()
   DoorClose:Play()
   Cooldown = false
end

Door.Touched:Connect(function(touch)
   if touch.Name == "CardColor" and Clearance[touch.Parent.Parent.Name] and Cooldown == false then
      Cooldown = true
      OpenDoor()
   end
end)

Um now I kinda fixed it…? I touch it with the card and it will open but then I have to touch it with the card for it to close again but it should do that on its own…

I’m not an expert with tweens but I’m pretty sure, if you are tweening the same door, you need to pause the first tween(open tween) then you can play the DoorClose tween.

But I shouldn’t need to pause it? Because if it opens isn’t the tween finished?

OOOF I didn’t have a Wait() in between them, but I still have one other problem. Is there a way to have it to if the player touches the door with the card while it is in the middle of a tween it won’t restart that tween?

Don’t need the cancels I have it timed so the other plays after the other finishes.

but what about the debounce? I think it should work but it doesn’t for some reason.

Oh okay, then just do this for your other problem

local function OpenDoor()
DoorOpen:Play()
wait(1)
   DoorClose:Play()
delay(--[[however longs it takes for the door to close --]], function()
   Cooldown = false
end)
end)

Okay thanks it is working perfect as of right now!!