Quote: "ive tried using if distance to player is less than # but it doesnt work."
There's nothing wrong with doing it this way but as xtom said you need to cycle through each enemy one at a time. You also don't want to be doing a lot of cycling/operations in your actual functions if you can get away with it - try to split the operations down. Having a single function to do everything will probably slow your code down as it'll be sitting in a sub-loop for longer than necessary
You want to set up something like (pseudocode):
movement(enemy)
lookforplayer(enemy,enemyxyz,playerxyz,enemydirection)
shoot at player(enemy)
etc, etc. . . .
and cycle through each of your enemies either with a (for/next) loop or a counter (a bit more flexible).