I am getting an error on all of my items

I am in the unity corce and on the towwer defence lesson.
here is my code


an here are the errors

Hi peanut,

NullReferenceException means that a reference (“link”) to an instance is missing. Double click on the error message to see to which line in your code it is referring. If you exposed a field in the Inspector, make sure that it’s not empty.

Did this help you fix the issue? Remember you can also look at the lecture code changes via the link in the Resources of each lecture.


See also:

what does that mean?

The screenshot of your console shows a NullReferenceException. I told you what you could try to fix it. Did you do what I suggested?

I don’t know what an exposed field is.

An exposed field means a variable that appers in the Inspector, for example, because it is public or was declared with the [SerializeField] attribute.

In your case, you look for a reference with GetComponent. Make sure the xyz component is able to find the TextMeshPro component.

can you send a screenshot telling me what that means. I still don’t really understand.

At a guess, you don’t have a TextMeshPro component on your object… or it’s in the wrong place. If that’s the case, that’ll mean your label is null and will come up with this error.

If you need a refresher about [SerializeField], I’d suggest to jump on to youtube and look at a video or two or go back over earlier parts of the course. It’ll be much easier for you to understand.

thank you so much! it works perfectly now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms