Weapon still hits after missing

I wanted to make a weapon,but for some reason it still kind of hits after missing,if i activate the tool,then wait for the animation to end and then touch the dummy with the weapon - the dummy will still take damage

Here’s the script in the tool:

local Tool = script.Parent
local Handle = Tool:WaitForChild("Handle")
local Idle = Tool:WaitForChild("Idle")
local Attack = Tool:WaitForChild("Attack")
local Debounce = false
local AnimDebounce = false


local Damage = 20





Tool.Equipped:Connect(function()

	local Motor6d = Instance.new("Motor6D")
	Motor6d.Part1 = Handle
	Motor6d.Part0 = Tool.Parent["Right Arm"]
	Motor6d.Parent = Handle
	Motor6d.Name = "Motor6d"
	
	local Humanoid = Tool.Parent:WaitForChild("Humanoid")
	
	local IdleLoaded = Humanoid:LoadAnimation(Idle)
	local AttackLoaded = Humanoid:LoadAnimation(Attack)
	IdleLoaded:Play()
	
	
	Tool.Activated:Connect(function()


		if AttackLoaded.IsPlaying == false and AnimDebounce == false then
			AnimDebounce = true
			IdleLoaded:Stop()
			AttackLoaded:Play()

			Handle.Touched:Connect(function(hit)
				if hit.Parent.Name ~= Tool.Parent.Name then
					if hit.Parent:FindFirstChild("Humanoid")  then
						local EnemyHumanoid = hit.Parent.Humanoid
						print("IsAHumanoid")
						if hit.Parent:FindFirstChild("Hittable")  then
							if Debounce ~= true and AttackLoaded.Stopped ~= true then
								Debounce = true




								EnemyHumanoid:TakeDamage(Damage)
								AttackLoaded.Stopped:Wait()
								task.wait(3)
								Debounce = false
							end
						end
					end
				end
			end)

			task.wait(3)
			AnimDebounce = false
			IdleLoaded:Play()

		else
			print("Debounce is true")
		end
	end)

	Tool.Unequipped:Connect(function()

		IdleLoaded:Stop()

		Handle:WaitForChild("Motor6d")



	end)
end)

How can i fix it? Thanks in advance

Remember to disconnect this if the animation ended.
Example:

local event = Handle.Touched:Connect(function(hit)
   print(hit)
end)
task.wait(3)
event:Disconnect()
1 Like

Your equipped, unequipped and activated event/signal handlers (callback functions) should be separated. You’re currently creating a new ‘Unequipped’ and ‘Activated’ event connection each time the tool’s ‘Equipped’ event/signal is fired.