Enemy Nav Mesh Agent Error. How to fix it? The player is not being followed by the enemy?

Hi, I was writing an Enemy AI code using a tutorial (ENEMY AI - Making an RPG in Unity (E10) - YouTube). I am running into this error and I am unable to understand how to fix it. I am pretty new in C#.

(Enemy Controller Code)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class EnemyController : MonoBehaviour
{

    public float lookRadius =90f;
    Transform target;
    NavMeshAgent agent;
    void Start()
    {
        target = PlayerManager.instance.player.transform;
        agent = GetComponent<NavMeshAgent>();
    }

    void Update()
    {
        float distance = Vector3.Distance(target.position, transform.position);

        if (distance <= lookRadius)
        {
            agent.SetDestination(target.position);
        }
    }
    void OnDrawGizmosSelected(){
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(transform.position, lookRadius);

    }
}


    
    

(Player Manager)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerManager : MonoBehaviour {

    #region Singleton

    public static PlayerManager instance;

    void Awake ()
    {
        instance = this;
    }

    #endregion

    public GameObject player;

    public void KillPlayer ()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

}

Hello.

You error means you are trying to give orders to a navmesh agent that is not placen in a navmesh surface.

First, be sure The surface is baked for navmesh system as a walkable surface

Second, be sure the NavMesh agent is placed on the surface. Sometines, it can seems to be on the surface, but not. For better results, use the function:

It’s like change it transform.position, but it places the object correctly on the nearest navmesh surface.

Read the manual and try it!

(if doesnt work, it means you are missing somethig else, also read the manual of navmeshagents)

good luck!