Problem with OnTriggerEnter

What I’m trying to do is have the object this script is attached to move toward it’s target when the player enters it’s trigger. It actually STARTS to work, but the object stops moving instantly after it starts. Meaning it just moves about an inch then stops. This is a script from the forums that I’ve slightly modified for what I need. Please note that I’m still a beginner at scripting, and after hours of frustration, I still can’t get this object to move towards the target when the player enters it’s trigger. Can someone please tell me what I’m doing wrong here?

var player : GameObject; 

var speed : float = 1;

function Start ()
{
player = GameObject.FindGameObjectWithTag(“CarrieTarget1”);

 if (!player) 
      Debug.Log ("ERROR could not find Player!"); 

}

function OnTriggerEnter (other : Collider) {

 if (!player) 
      return; 

 var distance = Vector3.Distance( player.transform.position, transform.position);

 if ( distance < 100  ) 
 { 
      Debug.Log ("player is close");
 
 if ( distance < 1 )
      
      Destroy (gameObject);
      
      var delta = player.transform.position - transform.position;
      delta.Normalize();
      
      var moveSpeed = speed * Time.deltaTime;
  
      transform.position = transform.position + (delta * moveSpeed);
} 
else 
{ 
      Debug.Log("not close yet " + distance); 
} 

}

Your problem is simple you use a collision function to check distance.

OnTriggerEnter only checks when you enter the zone, hence your guy is moving an inch and then stops, try to take the function off and put the whole thing in the Update from here:

if (!player) 
      return;

until the end. But remove one } at the end

var player : GameObject;
var target: Transform;
var controller: CharacterController;
var speed: int = 5;
var rotSpeed: float = 5;
var going:boolean;

    function Start(){
        controller  = GetComponent(CharacterController);
        player = GameObject.Find("Player");
        going = false;
        target.position = Vector3(0,0,0);   // here put the position of where you want your guy to go 
    }
    
    function Update(){
        
       
    
    // The player is within at less than 10m but more than 5m 
        if(Vector3.Distance(transform.position, player.transform.position) < 10)
         {
            going = true;
         }
         // Carrie goes.
         if(going){
            var forward : Vector3 = transform.TransformDirection(Vector3.forward);
            transform.rotation=Quaternion.Slerp(transform.rotation,Quaternion.LookRotation
                        (target.transform.position-transform.position),rotSpeed * Time.deltaTime);
            controller.SimpleMove(forward * speed);      
         }
         
           
    }   
    @script RequireComponent(CharacterController)

and tadaaa. Now your guy will only move if the player/object is within 10m and will follow him until the object is at a distance of more than 10m.