Direction of Attack

Hello community.
So, I'm working on a mini-platformer-type game, and I'm using the 'z' button to have my character attack enemies. The problem I'm having is, I don't know how to make the direction the character is attacking the same as the direction he's facing before he attacks, and then revert back to that same direction. Any scripting I need to use? Thanks in advance.
P.S. I'm kinda new, so a less complicated/more detailed solution would be greatly appreciated.
So, I'm working on a mini-platformer-type game, and I'm using the 'z' button to have my character attack enemies. The problem I'm having is, I don't know how to make the direction the character is attacking the same as the direction he's facing before he attacks, and then revert back to that same direction. Any scripting I need to use? Thanks in advance.
P.S. I'm kinda new, so a less complicated/more detailed solution would be greatly appreciated.