How can I disable a function of touched and TouchedEnded?

Well, basically I have a system that I want to deactivate when I stop playing the part that activates it, but I already tried to deactivate it with the if and elseif but they are still activated.

local health = 100

local bool = true
local Enabled = script.Parent:WaitForChild("Enabled")
local Damage = false

local HealthScreen = script.Parent:WaitForChild("Tronco"):WaitForChild("HealthGui")
local TextHealth = HealthScreen:WaitForChild("Frame"):WaitForChild("HealthText")
local Bar = HealthScreen:WaitForChild("Frame"):WaitForChild("BorderFrame"):WaitForChild("HealthBar")
local BarDamage = HealthScreen:WaitForChild("Frame"):WaitForChild("BorderFrame"):WaitForChild("Damagebar")

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local FolderMaterial = ReplicatedStorage:WaitForChild("DatosDeMaterialDrop"):WaitForChild("Wood")

local Players = game:GetService("Players")

local TweenService = game:GetService("TweenService")

local tweenInfo = TweenInfo.new(0.25)
local tweenInfo2 = TweenInfo.new(0.4)

local Touched = script.Parent:FindFirstChild("Touched")

local function Lumber(hit)
	local character = hit:FindFirstAncestorOfClass("Model")
	local Player = Players:GetPlayerFromCharacter(character)

	if Enabled.Value == false then
		while Enabled.Value == false and wait(0.05) do
			if health > 0 then
				if character then
					local HachaDeMetal = character:FindFirstChild("Hacha de metal")
					local HachaDePiedra = character:FindFirstChild("Hacha de piedra")
					local SistemTreeFolder = character:FindFirstChild("Sistemas"):FindFirstChild("SistemaDeTala")
					local HachaDeCuarzo = character:FindFirstChild("Hacha de cuarzo")
					local HachaDeObsidiana = character:FindFirstChild("Hacha de obsidiana")
					if HachaDeMetal or HachaDePiedra or HachaDeCuarzo or HachaDeObsidiana then
						if not Damage then
							Damage = true
							if HachaDePiedra then
								SistemTreeFolder:FindFirstChild("TalarArbolAnim").Value = true
								if SistemTreeFolder:WaitForChild("AcciónDeTala").Value == true then
									local DamageRamdom = math.random(3,5)
									health = health - DamageRamdom
								end
							elseif HachaDeMetal then
								SistemTreeFolder:FindFirstChild("TalarArbolAnim").Value = true
								if SistemTreeFolder:WaitForChild("AcciónDeTala").Value == true then
									local DamageRamdom = math.random(5,11)
									health = health - DamageRamdom
								end
							elseif HachaDeObsidiana then
								SistemTreeFolder:FindFirstChild("TalarArbolAnim").Value = true
								if SistemTreeFolder:WaitForChild("AcciónDeTala").Value == true then
									local DamageRamdom = math.random(11,19)
									health = health - DamageRamdom
								end
							elseif HachaDeCuarzo then
								SistemTreeFolder:FindFirstChild("TalarArbolAnim").Value = true
								if SistemTreeFolder:WaitForChild("AcciónDeTala").Value == true then
									local DamageRamdom = math.random(19,26)
									health = health - DamageRamdom
								end
							end
							wait(0.2)
							Damage = false
						end
					end
				end
			elseif health <= 0 and bool == true then
				if character then
					local respawn = math.random(60,120)
					bool = false
					health = 0
					TextHealth.Text = "0%"
					local SistemTreeFolder = character:FindFirstChild("Sistemas"):FindFirstChild("SistemaDeTala")
					SistemTreeFolder:FindFirstChild("TalarArbolAnim").Value = false

					local Hojas = FolderMaterial.Parent.Hojas:Clone()
					Hojas.Parent = script.Parent
					Hojas.Position = script.Parent.Hojas.Position

					for index, MaterialDesc  in ipairs(FolderMaterial:GetChildren()) do
						if MaterialDesc:IsA("BasePart") then
							local Clone = MaterialDesc:Clone()
							local Proximity = Clone:FindFirstChild("ProximityPrompt")
							Proximity.ObjectText = "Dueño original del material: ".. Player.Name
							local OwnerValue = Clone:FindFirstChild("Owner")
							OwnerValue.Value = Player.Name
							Clone.Position = script.Parent:WaitForChild("Hojas").Position
							Clone.Parent  = workspace.LumberjackSystem.Wood
						end
					end
					for i, parts in pairs(script.Parent:GetChildren()) do
						if parts:IsA("BasePart") then
							parts.Position = parts.Position - Vector3.new(0, 12, 0)
						end
					end
					wait(1)
					for count = 1, 1200  do
						for i, parts in pairs(script.Parent:GetChildren()) do
							if parts:IsA("BasePart") then
								parts.Position = parts.Position + Vector3.new(0, 0.01, 0)
								wait(0.001)
							end
						end
					end
				end
				health = 100 
				bool = true
			end

			TextHealth.Text = health.."%"
			local BarSize = TweenService:Create(Bar, tweenInfo, {Size = UDim2.new(health/100, 0, 1, 0)})
			local BarDamageSize = TweenService:Create(BarDamage, tweenInfo2, {Size = UDim2.new(health/100, 0, 1, 0)})
			BarSize:Play()
			BarDamageSize:Play()
			if health <= 0 then
				health = 0
				TextHealth.Text = "0%"
				BarSize:Play()
				BarDamageSize:Play()
			end
		end
	elseif Enabled.Value == true then
		Enabled.Value = false
	end
end

local function Finish(Hit)
	Enabled.Value = true
	local character = Hit:FindFirstAncestorOfClass("Model")
	local Player = Players:GetPlayerFromCharacter(character)
	if character then
		local SistemasFolder = character:FindFirstChild("Sistemas")
		if SistemasFolder then
			local SistemaDeTala = SistemasFolder:FindFirstChild("SistemaDeTala")
			if SistemaDeTala then
				local AnimValue = SistemaDeTala:WaitForChild("TalarArbolAnim")
				AnimValue.Value = false
				wait()
				Enabled .Value= true
				wait()
				Enabled.Value = true
			end
		end
	end
end

Touched.Touched:Connect(Lumber)
Touched.TouchEnded:Connect(Finish)

Save the connecting in the variables, then disconnect whenever you need. :Connect returns RBXScriptConnection which you can disconnect.