Event Misfiring From Sword

I’m trying to fire the event when a part comes in contact with the handle while the animation is playing

Once activated, it is constantly detecting for a collision with another part.

Even after the animation has stopped playing, it is still running

print(hitPart);
ClickEvent:FireServer(LocalPlayer, hitPart);

script:

script.Parent.Activated:Connect(function()
	local Humanoid = Character.Humanoid;

	local AnimationTrack = Humanoid:LoadAnimation(Animation);
	AnimationTrack:Play()
	if AnimationTrack.IsPlaying == true then
		Sword.Touched:Connect(function(hitPart)
			print(hitPart);
			ClickEvent:FireServer(LocalPlayer, hitPart);
		end);
	end;
end);

You’re connecting the sword touched event here, but you never disconnect the event, so it will continue listening for touches. To stop listening for touches, you have to disconnect the event.

You could do something like this, which disconnects after it touches something

		local connection
		connection = Sword.Touched:Connect(function(hitPart)
			connection:Disconnect()
			print(hitPart);
			ClickEvent:FireServer(LocalPlayer, hitPart);
		end);

Or you could disconnect the event somewhere else, like when the animation stops playing.