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)