also consider making a variable called "state" on the player. Then change this to the state you want your character to be in...
states:
"normal"
"attack"
"defend"
"dying"
"dead"
"lowhealth"
etc...
then set and use those states to differentiate code... just make sure you always set them with one action, and end them with some other event like... animation is now over.
so in your attack, hit the button set state to "attack"
then make an event trigger when attack animation finishes, set the state back to normal.
then your idle animation can be triggered only if player state = "normal"