Im trying to make a door that locks during a lockdown and only certain cards can open the door. But for some reason it only opens during a lockdown for a Tier 3 Administrator but none of the others.
local Clearances = {
["Tier 3 Administrator"] = true,
["Tier 2 Administrator"] = true,
["Tier 1 Administrator"] = true,
["Tier 3 Security"] = true,
["Tier 2 Security"] = true,
["Tier 1 Security"] = true,
["Armoury Access"] = true,
["Level 5"] = true,
["Level 4"] = true,
["Level 3"] = true,
["Level 2"] = true,
["Level 1"] = true,
}
local LockDownCards = {"Tier 3 Administrator","Tier 2 Administrator","Tier 1 Administrator"}
local DoorPart1 = script.Parent.Door
local DoorPart2 = script.Parent.Window
local StatusPart = script.Parent.StatusPart
local DoorIsBusy = false
local DoorIsOpen = false
local LockDown_Enabled = false
for i, value in pairs(LockDownCards) do
print(LockDownCards[i])
end
function Activated(Part)
if DoorIsOpen == false and DoorIsBusy == false and LockDown_Enabled == false and Clearances[Part.Parent.Name] then
Open()
elseif DoorIsBusy == false and DoorIsOpen == true and LockDown_Enabled == false and Clearances[Part.Parent.Name] then
Close()
elseif DoorIsBusy == false and LockDown_Enabled == true and Part.Parent.Name ~= LockDownCards[1 or 2 or 3] and Clearances[Part.Parent.Name] then
LockDown()
elseif DoorIsBusy == false and LockDown_Enabled == true and DoorIsOpen == false and Part.Parent.Name == LockDownCards[1 or 2 or 3] and Clearances[Part.Parent.Name] then
Open()
elseif DoorIsBusy == false and LockDown_Enabled == true and DoorIsOpen == true and Part.Parent.Name == LockDownCards[1 or 2 or 3] and Clearances[Part.Parent.Name] then
Close()
end
end
function Open()
DoorIsBusy = true
DoorPart1.DoorMove_Sound:Play()
for i = 10, 50 do
wait(0.01)
DoorPart1.CFrame = DoorPart1.CFrame * CFrame.new(-0.1,0,0)
DoorPart2.CFrame = DoorPart2.CFrame * CFrame.new(-0.1,0,0)
StatusPart.CFrame = StatusPart.CFrame * CFrame.new(-0.1,0,0)
end
wait(1)
StatusPart.SurfaceGui1.Open.Text = "[ OPEN ]"
StatusPart.SurfaceGui1.Open.TextColor3 = Color3.new(0, 255, 0)
StatusPart.SurfaceGui2.Open.Text = "[ OPEN ]"
StatusPart.SurfaceGui2.Open.TextColor3 = Color3.new(0, 255, 0)
DoorIsBusy = false
DoorIsOpen = true
end
function Close()
DoorIsBusy = true
DoorPart1.DoorMove_Sound:Play()
for i = 10, 50 do
wait(0.01)
DoorPart1.CFrame = DoorPart1.CFrame * CFrame.new(0.1,0,0)
DoorPart2.CFrame = DoorPart2.CFrame * CFrame.new(0.1,0,0)
StatusPart.CFrame = StatusPart.CFrame * CFrame.new(0.1,0,0)
end
wait(1)
StatusPart.SurfaceGui1.Open.Text = "[ CLOSED ]"
StatusPart.SurfaceGui1.Open.TextColor3 = Color3.new(255, 0, 0)
StatusPart.SurfaceGui2.Open.Text = "[ CLOSED ]"
StatusPart.SurfaceGui2.Open.TextColor3 = Color3.new(255, 0, 0)
DoorIsBusy = false
DoorIsOpen = false
end
function LockDown()
if DoorIsOpen == false then
DoorPart1.LockDown_Sound:Play()
DoorIsBusy = true
DoorPart1.DoorMove_Sound:Play()
for i = 10, 25 do
wait(0.01)
DoorPart1.CFrame = DoorPart1.CFrame * CFrame.new(-0.1,0,0)
DoorPart2.CFrame = DoorPart2.CFrame * CFrame.new(-0.1,0,0)
StatusPart.CFrame = StatusPart.CFrame * CFrame.new(-0.1,0,0)
end
for i = 10, 25 do
wait(0.01)
DoorPart1.CFrame = DoorPart1.CFrame * CFrame.new(0.1,0,0)
DoorPart2.CFrame = DoorPart2.CFrame * CFrame.new(0.1,0,0)
StatusPart.CFrame = StatusPart.CFrame * CFrame.new(0.1,0,0)
end
wait(1)
StatusPart.SurfaceGui1.Open.Text = "[ CLOSED ]"
StatusPart.SurfaceGui1.Open.TextColor3 = Color3.new(255, 0, 0)
StatusPart.SurfaceGui2.Open.Text = "[ CLOSED ]"
StatusPart.SurfaceGui2.Open.TextColor3 = Color3.new(255, 0, 0)
DoorIsBusy = false
end
end
function LockDownActive()
if workspace.SiteStats.LockDown.Value == true then
LockDown_Enabled = true
StatusPart.SurfaceGui1.Locked.Text = "[ LOCKED ]"
StatusPart.SurfaceGui1.Locked.TextColor3 = Color3.new(255, 85, 0)
StatusPart.SurfaceGui2.Locked.Text = "[ LOCKED ]"
StatusPart.SurfaceGui2.Locked.TextColor3 = Color3.new(255, 85, 0)
if DoorIsOpen == true and DoorIsBusy == false then
print("Closing Door")
Close()
end
elseif workspace.SiteStats.LockDown.Value == false then
LockDown_Enabled = false
StatusPart.SurfaceGui1.Locked.Text = "[ UNLOCKED ]"
StatusPart.SurfaceGui1.Locked.TextColor3 = Color3.new(255, 255, 0)
StatusPart.SurfaceGui2.Locked.Text = "[ UNLOCKED ]"
StatusPart.SurfaceGui2.Locked.TextColor3 = Color3.new(255, 255, 0)
end
end
script.Parent.CardReader1.Touched:Connect(Activated)
script.Parent.CardReader2.Touched:Connect(Activated)
workspace.SiteStats.LockDown.Changed:Connect(LockDownActive)

2 comments
Thanks man, it worked perfectly.
You are welcome. ;3