and if you want to attack within a certain range
system compare 2 values
abs(distance(player.x,enemy.x,o,o))
is smaller than 400(this is pixels)
sorry my bad.forgot something.
then make subevent player.x <enemy.x simulate enemy left
and
player.x>enemy.x simulate enemy right