You can do this multiple ways, you can check what angle the player sprite has and go from there, or you can do the easy way and add 2 sprites one named "leftbox" 1 named "rightbox", make them invisible on startup, then if your player is walking left for example, you want to mirror the player sprite(im guessing you have done this).
So you do "on Z is clicked" , but also check if "Player is mirrored", you can invert this option and it will be like "player is not mirrored".
So if player IS MIRRORED, shoot towards object LEFTBOX, if player is not mirrored, shoot towards object RIGHTBOX.
Im at work so i just quickly answered, if you need help you can add me on discord. #ironside6435 add me and i will answer when i can :)
P.S: OOS below has a solution for your angle