Enemy Find the Player Location and start shoot " AI "

Enemy Find the Player Location and start shooting AI (Maintaining a Small Distance from Player). Can u Help me ,

This script for Enemy AI;

Transform mainPlayer;

float attackDistance = 5.0f;

void Start()
{

mainPlayer = GameObject.Find(“MainPlayer”).transfom;

}

void Update(){

Move(); //Your move function.

if(Vector3.Distance(mainPlayer.position,transform.position)< attackDistance ){

ATTACK>();//Your Attack function

}