If you give the enemy an attack range variable, you can proceed as follows...
enemy distance(enemy.x,enemy.y,player.x,player.y) is less than a distance you specify, set an attack variable to 1
else set attack to 0
then enemy attack is greater than 0, set enemy y to player y
You could set them to randomly walk towards player by having them set angle to player only when a certain animation frame is played...
enemy is on screen, attack =0
animation frame =2 set enemy movement to player x,player y this will set the enemy edging towards the player...