How to solve !

im working on a enemy script to chase te player if i start my game the enemy is already following my player but the player is not in range how to solve it !

using UnityEngine;
using System.Collections;

public class MOB3 : MonoBehaviour
{
    public Animator anim;

    public float speed;
    public float range;

    public CharacterController controller;
    public Transform player;
   

    void Start()
    {
        anim = GetComponent<Animator>();
    }

    void Update()
    {

        if (inRange())
        {
            transform.LookAt(player.position);
            anim.SetBool("walk", true);



        }
        else if (!inRange())
        {
            Chase();
            anim.SetBool("walk", false);

        }
    }

    bool inRange()
    {
        if (Vector3.Distance(transform.position, player.position) < range)
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    void Chase()
    {
        transform.LookAt(player.position);
        controller.SimpleMove(transform.forward * speed);
        anim.SetFloat("Speed", 1);

    }

}

@Valentinon13 You’re calling the chase method when the player is not in range. Your update should look like:

   void Update()
     {   
         if (inRange())
         {
             transform.LookAt(player.position);
             Chase();
             anim.SetBool("walk", true); 
         }
         else if (!inRange())
         {  
             anim.SetBool("walk", false); 
         }
     }