local a=false local R=false local function l(a,R)local l=a.Character if l then local g=a.Backpack:GetChildren()local Q=l:FindFirstChildOfClass("\084\111\111\108")if Q then table.insert(g,Q)end for a,l in pairs(g)do if l and(game.ServerStorage.CLEARANCE_TREE:FindFirstChild(tostring(R))):FindFirstChild(l.Name)then return true end end end return false end local function g(g)if R==true then return end local Q=g.Character if Q then local I=Q:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")if I and I.Health>0 then R=true prompt.MaxActivationDistance=0 if l(g,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()a=not a if a==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 R=false end end end prompt.Triggered:Connect(g)
---------------------------------dont you dare change the speed without editing the sound to match
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(0.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(0.1)
				reader.Light.Color = Color3.new(1, 1, 1)
			end

			prompt.MaxActivationDistance = 5

			cooldown = false
		end
	end
end

prompt.Triggered:Connect(onPromptTriggered)
