Animation Event and Touched Event

I have an animation with an Animation Event, and when it reaches that point, I want it to check if anyone is touching a certain object. If anyone is touching that object during the event, it’ll damage you.

The issue is, even with a debounce, it damages the player way more than it should.

I’ve tried setting the CanTouch on the object to false after it damages the player, but that hasn’t even worked. Sorry if this doesn’t make sense, I’m very tired.

This is my code for it

local indb = true
swing1:GetMarkerReachedSignal("Contact"):Connect(function()
		blade.Touched:Connect(function(hit)				
			if hit.Name == "HumanoidRootPart" and indb then
				indb = false
					blade.CanTouch = false
					hit.Parent.Humanoid:TakeDamage(50)
					hrp.HitPlayer:Play()
					print("hit player")
				end
			end)
hrp.HitGround:Play()
end)

I feel like there’s another way to do this, but if there is, I have no idea what that would be.

In summary, I want this object to only damage the player during the animation event, and only once. After that I want it to not be able to hurt the player until the animation replays and it reaches the event again.

so the player takes 50 damage more than once in a row (I assume that kills them instantly)?

Yeah that’s what happens pretty much

swing1.Stopped:Wait() --Waits for animation to 'stop' (end).
indb = true --Set debounce variable back to 'true'.

You also have a memory leak in your code (due to nested event connections) that you’ll need to fix.

try changing

if hit.Name == "HumanoidRootPart" and indb then

to

if hit.Name == "HumanoidRootPart" and indb == true then