NullReferenceException: Object reference not set to an instance of an object (560230)

Hello! So I am just starting to use C# on Unity. I am creating a simple game and I am done with Positions, Movement, etc. But after some hours of coding and adding more to the game, I suddenly got the “NullReferenceException” Error. I looked on other threads and had answers but not like mine. I am having trouble with this and I am confused at the same time. My Error says:
NullReferenceException: Object reference not set to an instance of an object
Patrol.Update () (at Assets/Scripts/Patrol.cs:18)

I am hoping someone can fix it for me! Here is my code with the error that i’m confused with.

using UnityEngine;
using System.Collections;

public class Patrol : MonoBehaviour {
    public Transform[] patrolPoints;
    public float moveSpeed;
    private int currentPoint;


    // Use this for initialization
    void Start () {
        transform.position = patrolPoints[0].position;
        currentPoint = 0;
    }
   
    // Update is called once per frame
    void Update () {
        if (transform.position == patrolPoints [currentPoint].position)
        {
            currentPoint++;
        }

        if (currentPoint >= patrolPoints.Length)
        {
            currentPoint = 0;
        }

        transform.position = Vector3.MoveTowards (transform.position, patrolPoints[currentPoint].position, moveSpeed * Time.deltaTime);
    }
}

Without seeing how you’re assigning the patrol points(I assume you’re doing it in the Inspector), my first guess is to use a debugger and check to see if the last item in your patrolPoints array is null (i.e. did an empty transform make its way onto the list from the inspector?)