--LockController


Closed = true

function LockUnlock()
	if script.Parent.Locked.Value == true then
		script.Parent.SwitchArm.Interactive.ClickDetector.MaxActivationDistance = 0
	else
		script.Parent.SwitchArm.Interactive.ClickDetector.MaxActivationDistance = 10
	end
end

script.Parent.Enclosure.Touched:connect(function(P)
	if P ~= nil and P.Parent ~= nil and P.Parent:FindFirstChild("CardNumber") ~= nil  and P.Parent.CardNumber.Value == 0 then
		if Closed == true then
			script.Parent.Locked.Value = false
			Closed = 1
			LockUnlock()
			wait(1)
			Closed = false
			return
		end
		if Closed == false then
			script.Parent.Locked.Value = true
			Closed = 1
			LockUnlock()
			wait(1)
			Closed = true
			return
		end

	end
end)

LockUnlock() --Check
