2D game attack system for AI

I see that people use animation to use attack in 3D games but in my 2D game I cant see to understand if I even can use animations so I use for the AI “set Flipbook” when close to me for the attack Flipbook but then the AI attack multiple times how can I make him attack only once?