If i understand you want your player to not get damaged if collide with enemies when he attack?
You have to run to event when the enemies collide with your player and compare if player does not play attack animations.
If you want to add a hitbox make an empty sprite and create it when the player attacks.
So if player playing animation attack and frame is equal to "what ever" -> system create hitbox.
Hitbox on collision with enemies -> destroy hitbox.
Just notice if you have your player flipped or mirrored you have to specify the position of hitbox.
And another advise , destroy your hitbox on animation attack end so your player do not carry it anymore.