counting how many times a specific animation plays

Hello u unity users.
How would you count how many times a specific animation plays from a random range of animations? In this case I want “swing” to play 5 Times, // then do something.

(“Roll”,“spin”,“swing”)

you could have an int counter so after ever time the animation plays add one value to it like so:

public int counter = 0;

animation.Play(playur animation);
counter +=1;

or for a specific animation

if (animation.Play(ur specific animation)) { 
counter +=1; 
}

if(counter >= 5) {
//do ur thing
//reset the counter
counter == 0;
}

He even forgot to close the “()” x),
thank you thorney !