Why Do I get this error: IEnumerator does not exist in the current context?

using UnityEngine;
using UnityEngine.AI;

// C# example.

public class code : MonoBehaviour
{
public GameObject arr = new GameObject[12];
// public GameObject point0;
// public GameObject point1;
// public GameObject point2;
// public GameObject point3;
// public GameObject point4;
// public GameObject point5;
// public GameObject point6;
// public GameObject point7;
// public GameObject point8;
// public GameObject point9;
// public GameObject point10;
// public GameObject point11;
NavMeshAgent agent;
public GameObject cube;
public float range = 650f;

void Start()
{

    agent = GetComponent<NavMeshAgent>();
}
void Update()
{  
    
    Debug.Log(rnd);

    RaycastHit hit;
    // Does the ray intersect any objects excluding the player layer
    if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward),  out hit))
    {
        if (hit.collider.gameObject.tag == "cube")
        {

            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * range, Color.green);
            Debug.Log("Did Hit");
            // agent.isStopped = false;

             agent.SetDestination(cube.transform.position);

             

        }

        else
        {
            Debug.Log("It hit, but not in the right spot");
            Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * range, Color.yellow);
            
            StartCoroutine(GoToDestination());
        }
    }
    else
    {
        Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * range, Color.red);
        Debug.Log("Did not Hit");
        StartCoroutine(GoToDestination());
        // agent.isStopped = true;
        

    }
}

public IEnumerator GoToDestination()
{

    bool found = false;
    while(found == false)
    {
        int rnd = Random.Range(0,12);
             if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward),  out hit))
            {

                     if (hit.collider.gameObject.tag == "cube")
                    {

                              Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * range, Color.green);
                               Debug.Log("Did Hit");
            // agent.isStopped = false;

                                   break;

             
                    }

                  else
                   {
                        Debug.Log("It hit, but not in the right spot");
                        Debug.DrawRay(transform.position, transform.TransformDirection(Vector3.forward) * range, Color.yellow);
                         agent.SetDestination(arr[rnd].transform.position);
                    }
    }

    else
    {
       agent.SetDestination(arr[rnd].transform.position);
       yield return new WaitForSeconds(10f);
    }
    }

    Update();

}

}

You have trimmed out Namespaces that you think you don’t need. That’s generally a good thing to do and I, too, try to do that as much as I can.

However, you’ve gone too far… IEnumerator is part of the .Net framework and so you need to add this at the top of your file:

Using System.Collections;

Oh thank you! For some reason earlier in this project I had some namespaces and I deleted them because my random didn’t work! FYI, I forgot to add RaycastHit hit; which I added later. Also, thank you very much. My code worked, I wrote a better version of it.