Help with detecting a object hit while animation is playing

I need help with this script that is supposed to detect when an object is hit while playing an animation.

function OnHit(OBJ)
	if OBJ.Parent:FindFirstChild("Humanoid") and not OBJ.Parent:IsDescendantOf(Player.Character) and not OBJ.Parent:IsA(Tool)   then
		if isAnimating == true then
			toolHit = true
			Tool.Handle.Hit:Play()
			ThrowEvent:FireServer(OBJ.Parent.Name)
			isAnimating = false
			task.wait(0.5)
			debounce = false
			toolHit = false
		end

	elseif not OBJ.Parent:FindFirstChild("Humanoid") and not OBJ.Parent:IsDescendantOf(Player.Character) and not OBJ.Parent:IsA(Tool)  then

		if isAnimating == true then
			toolHit = true
			isAnimating = false
			task.wait(0.5)
			debounce = false
			toolHit = false
		end

	end
end

Tool.Activated:Connect(function()

	if debounce == false then

		debounce = true

		if isAnimating == false then
			isAnimating = true

			Anim:Play()
			
			Tool.Handle.Touched:Connect(function(Hit)
				
				if isAnimating == true then
										
					OnHit(Hit)
					print("Hit An Object")
				end


			end)
			
			Tool.Handle.TouchEnded:Connect(function(Hit)
				
				if isAnimating == false then
					
					print("Animation Ended")
					
				end
				
			end)
		
		end
	end
end)