NullReferenceException error

so i was watching toutorials and i had code for AI and i reloaded to find it broken

using UnityEngine;

public class enemy : MonoBehaviour {

public float speed = 10f;

private Transform target;

private int waypointIndex = 0;

 void Start()
{
    target = waypoint_movement.points[0];
}

  void Update()
{  //movement and spped checks 
    Vector3 dir = target.position - transform.position;

    transform.Translate(dir.normalized * speed * Time.deltaTime , Space.World);

    if (Vector3.Distance(transform.position , target.position) <=0.2f)
    {
        GetNextWaypoint();
    }

}

//gets next waypoint 
void GetNextWaypoint()
{

    if(waypointIndex >= waypoint_movement.points.Length -1)

    {
        Destroy(gameObject);
        return;
    }
    waypointIndex++;
    target = waypoint_movement.points[waypointIndex];

}

}

This error means that you are trying to do something with the variable which are currently equal to “null”.

Double click on the error in the Unity console and it will highlight the line with the error, so it will be easy to find it.
Also number of line will be stated in the debug log console.

In your case, there is multiple places where error may occurs. You should say number of line.