Hello guys i searched it for on internet but i find nothing. Can you describe me how can i make this?

I want to make a script like:

when npc attacks or uses the tool play the animation.

how can i make this please tell me.