--- AS OF NOW THIS ONLY WORKS ON THUNDERBOLTS



local hingePos = script.Parent.Hinge.Position
local handle = script.Parent.Handle
local off = false
local setname = "On"


local c1 = script.Parent.Handle.CFrame
local c2 = script.Parent.HandleOff.CFrame
local c3 = script.Parent.HandleOn.CFrame

local dd = false
local ud = false

function down()
	dd = true
	for i = 0.1,1, 0.01 do
		script.Parent.Handle.CFrame = c1:Lerp(c2,i)
		wait()
	end
	dd = false
end

function up()
	ud = true
	for i = 0.1,1, 0.01 do
		script.Parent.Handle.CFrame = script.Parent.Handle.CFrame:Lerp(c3,i)
		wait()
	end
	ud = false
end


handle.ClickDetector.MouseClick:Connect(function()
	if off == false then
		off = true
		if dd == true then
			
		else
			down()
		end
		local n = script.Parent.Parent:FindFirstChild(setname)
		assert(n,"Error Finding Name!")
		n.Value = false
		n.Name = "(Disabled)"
		setname = "(Disabled)"
	else
		off = false
		if ud == true then
			
		else
			up()
		end
		local n = script.Parent.Parent:FindFirstChild(setname)
		assert(n,"Error Finding Name!")
		n.Name = "On"
		setname = "On"
	end
end)
