How to make a follow AI

I know there are a lot of questions about this but all of them are outdated or don’t work. So I want a basic ragdoll AI that follows the Player until it touches the player. But none of the code works with ragdolls. Here is the code I saw and did.

var Player : Transform;
 var MoveSpeed = 4;
 var MaxDist = 10;
 var MinDist = 5;
 
 
 
 
 function Start () 
 {
 
 }
 
 function Update () 
 {
     transform.LookAt(Player);
     
     if(Vector3.Distance(transform.position,Player.position) >= MinDist){
     
          transform.position += transform.forward*MoveSpeed*Time.deltaTime;
 
           
           
          if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
              {
                 //Here Call any function U want Like Shoot at here or something
    } 
    
    }
 }

But that did not work. Also, the Player is called Player and enemy called jeff.
THANKS!

You might want to use “transform.position = Vector3.MoveTowards();”

hi

try this

 transform.LookAt(Player.transform);
                    transform.position += transform.forward * movementSpeed * Time.deltaTime;

@Callz01 Which line? Thanks for the help so far =)

You got your answer but this will also help you > VIRIDAX GAME STUDIOS
Basic AI Controller
VIRIDAX GAME STUDIOS
Basic AI Controller