NullReferenceException FuelCellGlowLookAt.Update () (at Assets/Scripts/Misc/FuelCellGlowLookAt.js:7)

I'm getting this error, does anyone know how to fix it: NullReferenceException FuelCellGlowLookAt.Update () (at Assets/Scripts/Misc/FuelCellGlowLookAt.js:7)

This is the script:

// fuelCellGlowLookAt: Forces the object to always face the camera.
// (Used for the 'glowing halo' effect behind the collectable items.)

function Update() 
{
    transform.LookAt(Camera.main.transform);
}

function OnBecameVisible()
{
    enabled = true; 
}

function OnBecameInvisible()
{
    enabled = false;    
}

Nullreference exception to my knowledge usually means you have a script attached to a gameObject, but there's something you haven't declared yet. For instance if you have var bulletPrefab : Transform; in your script so you can then attach a prefab to it later but you forget to do this, you'll get this error message.

When you click on this error in the compiler, look at your hierarchy screen. It should highlight the gameObject that is causing the error. See if you forgot to attach something here. If it's not that, all I can guess is that maybe you have deleted your main camera and are using a normal one? Because the script is referencing the main camera specifically.

Hope this helps, I'm a bit of a newb myself. :)

I guess you don't have a camera that is tagged as "MainCamera".

`Camera.main` returns the first Camera that is tagged MainCamera. If there is no cam, it will return null. You get this error because you try to access the `transform` of this null reference.