How do i make my attack function not work whilst animation playing?

I have an attack function and it happens when i left click but i every time i click it applies damage to the enemy whereas the animation still plays once. so if i click 5 times rapidly it will dead 5 lots of damage whereas the animation will only play once or twice. how can i make it work so that i cannot deal damage whilst the animation is playing and have to wait for the next swing?

Set a bool to true when the anim starts playing, and only process mouse clicks while that bool is false. When the anim stops set the bool back to false.