NullReferenceException on seeker.StartPath()[Solved]

Edit:
It always seems like I find the solution after I make a post.
The issue was that my EnemyAI script was attached to another gameobject. So getComponent finds an empty gameobject and seeker returns as null.

I am following along a Brackey’s tutorial

and I am running into an issue.

“NullReferenceException: Object reference not set to an instance of an object
EnemyAI.Start () (at Assets/Scripts/Game Scripts/EnemyAI.cs:41)”

Someone else had this issue in this thread:

Their problem was that they had not attached a seeker component to the gameobject with the AI script.

However, I am pretty sure I am not making that mistake.

There is a seeker component attached. Here is some of the code of the AI script. The highlighted line is the issue.

I did notice something. If I changed
seeker = GetComponent(); to
seeker = FindObjectOfType();,
the error disappears. However, that brings other issues as well. Any help would be appreciated. Thanks.

NullReferenceException means that you are trying to use a reference variable whose value is Nothing/null . When the value is Nothing/null for the reference variable, which means that it is not actually holding a reference to an instance of any object that exists on the heap.

string str = null;
str.ToUpper();

Above c# code throws a NullReferenceException at the second line because you can’t call the instance method ToUpper() on a string reference pointing to null. So, check your code once again.