Problem With Unity Tutorial Project - Stealth

Hi everyone.

I’m learning who to use Unity from Unity’s made tutorial for a game step by step, but I think that because I have newer version then there is in the video I’m trying to write a script as they do and it shows me that there’s an Error.

My problem is in this line:
alarm = GameObject.FindGameObjectWithTag (“Alarm”).GetComponent ();

But I’m pretty sure that only see the code isn’t much helpful…
So here a link to the video:

Thank you to all the helpers, and even the one’s who only read it.

Post the error here. Can’t really help you if you don’t give us the error. Perhaps you haven’t set the “Alarm” tag yet?

Here the problem:
NullReferenceException: Object reference not set to an instance of an object
LastPlayerSighting.Awake () (at Assets/Scripts/LastPlayerSighting.cs:22)

Is it helps?

It does. Is there an object in the scene with the tag of “Alarm” (not “alarm”!) and does that object have a component attached to it called “AlarmLight”? If any of those are missing you’ll get that error.

No, there isn’t an object in the scene with the tag of “Alarm”, but I have a line:
private AlarmLight alarm;
(Reference to the AlarmLight script)

Well, that’s your problem then. Put one in and make sure it has the script “AlarmLight” attached to it. I suspect it needs to be a light of some sort but I’m not going to watch that entire video just to find out for you.

Ok, so can you tell me how to attach the script “AlarmLight” to it?

With the “Add Component” button. Or you can drag the script right on to the object. Doesn’t the tutorial tell you how to do all this? if not, you need to go back and do some very beginner tutorials. This kind of stuff should be the first thing you learn.

I had the same problem. I tried correcting possible typos. It didn’t help. I tried identifying what object wasn’t found by breaking the statement into two. It was the light that wasn’t found. Then I discovered that I had accidentaly disabled the light_alarm_directional when I played around with it before I wrote the script.