// this will turn to player and move to him
vec_set(temp, player.x);
vec_sub(temp, my.x);
vec_to_angle(my.pan, temp);
move.x=2*time;
ent_move(move,nullvector);

//this will attack him if distance between them is less then 50
if (vec_dist(my.x,player.x)<50)
{
//attack script here
}

I suggest you read AUM megazines.