local v=false local s=false local function C(v,s)local C=v.Character if C then local S=v.Backpack:GetChildren()local F=C:FindFirstChildOfClass("\084\111\111\108")if F then table.insert(S,F)end for v,C in pairs(S)do if C and(game.ServerStorage.CLEARANCE_TREE:FindFirstChild(tostring(s))):FindFirstChild(C.Name)then return true end end end return false end local function S(S)if s==true then return end local F=S.Character if F then local O=F:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if O and O.Health>0 then s=true prompt.MaxActivationDistance=0 if C(S,2)==true then reader.Light.Color=Color3.new(0,1,0)readerPrimary.ReaderAccept:Play()task.wait(.1)reader.Light.Color=Color3.new(1,1,1)doorPrimary.Part.SlidingDoor:Play()v=not v if v==true then prompt.ActionText="\079\112\101\110"alarmPart.Alarm:Play()doorCloseTween:Play()else prompt.ActionText="\067\108\111\115\101"doorPrimary.Part.Start:Play()doorOpenTween:Play()end task.wait(4)alarmPart.Alarm:Stop()else reader.Light.Color=Color3.new(1,0,0)readerPrimary.ReaderDeny:Play()task.wait(.1)reader.Light.Color=Color3.new(1,1,1)end prompt.MaxActivationDistance=5 s=false end end end prompt.Triggered:Connect(S)

local closed = false
local cooldown = false

local function checkClearance(plr, requiredClearance)
	local char = plr.Character

	if char then
		local inventory = plr.Backpack:GetChildren()
		local heldTool = char:FindFirstChildOfClass("Tool")
		if heldTool then
			table.insert(inventory, heldTool)
		end

		for i,tool in pairs(inventory) do 
			if tool and game.ServerStorage.CLEARANCE_TREE:FindFirstChild(tostring(requiredClearance)):FindFirstChild(tool.Name) then
				return true
			end
		end
	end

	return false
end

local function onPromptTriggered(plr)
	if cooldown == true then return end
	
	local char = plr.Character
	if char then
		local hum = char:FindFirstChildOfClass("Humanoid")
		
		if hum and hum.Health > 0 then
			cooldown = true
			
			prompt.MaxActivationDistance = 0
			
			if checkClearance(plr, 2) == true then
				reader.Light.Color = Color3.new(0, 1, 0)
				readerPrimary.ReaderAccept:Play()
				task.wait(.1)
				reader.Light.Color = Color3.new(1, 1, 1)
				
				------------------
				doorPrimary.Part.SlidingDoor:Play()
				
				closed = not closed
				if closed == true then
					prompt.ActionText = "Open"
					
					alarmPart.Alarm:Play()
					doorCloseTween:Play()
				else
					prompt.ActionText = "Close"
					
					doorPrimary.Part.Start:Play()
					doorOpenTween:Play()
				end
				
				task.wait(4)
				
				alarmPart.Alarm:Stop()
			else
				reader.Light.Color = Color3.new(1, 0, 0)
				readerPrimary.ReaderDeny:Play()
				task.wait(.1)
				reader.Light.Color = Color3.new(1, 1, 1)
			end
			
			prompt.MaxActivationDistance = 5
			
			cooldown = false
		end
	end
end

prompt.Triggered:Connect(onPromptTriggered)
