NullReferenceException:

Hi,
I am trying to figure out what this error is and why I am getting it.

There are a few examples online but I can not see how it relates to what I am doing.

cameraFollow

var target : GameObject;

function Update () {
	var camStatus = GetComponent(floorScript);	
	if(camStatus.camSwitch == true)
	{
		
	}
	
	if(camStatus.camSwitch == false)
	{

	}
}

cameraReload

function Update () {
	var camStatus = GetComponent(floorScript);
	if(camStatus.camSwitch == true)
	{
		return;
	}
	if(camStatus.camSwitch == false)
	{
		
	}
}

floor

var brainActive : boolean = true;
var camSwitch : boolean = false;

function OnTriggerEnter (other : Collider) {
	if(other.tag == "Player")
	{	

		camSwitch = true;
		
		}
}

There is no script called floorScript attached to that GameObject. Your GetComponent is returning null.

NullReferenceException means that the object doesn’t exist. Namely, in the cameraFollow script, camStatus is null because GetComponent is returning null. If all the scripts are on the same object, you want to use gameObject.GetComponent(…);. If it’s on a different object, you have to have a reference to it before getting a component from it.

Another tip: Don’t use GetComponent in an Update. Do this

var camStatus : floorScript;

function Start()
{
//get your component here
}
function Update()
{
//use your variable here
}

Right.
You are right. I thought I tried that. Anyhow, problem was I only did for one script not both. Thanks!