First you need to have the animation for the sprite, after that you will need a separate sprite pinned to an image point near the weapon for collision detection. Then you add an keyboard object to your project and add an event on key space pressed, and as action play the animation, make a wait system expression( 2 seconds or something like that), and reset the animation back to default.
As a sub event add the collision detection, use the sprite pinned to the image point and check if its touching the enemy, if it does subtract from his heath.