Light problems

Hello im having a problem with some errors i get that i do not understand why im getteing. im posting a picture of my unity and my code below. this code should be able to turn on and off a torch. but i cant get it to work with the ligt.

Picture of the problem

The code is following:

//Light script on / off

var lightNr : int = 0;
var OffLight	: float = 0.0;
var OnLight		: float = 2.0;

private var light : GameObject;

function Start()
{
	if(lightNr == 0)
	{
		isOn = true;
		light.intensity = OnLight;
	}
	else
	{
		isOn = false;
		light.intensity = OffLight;
	}
}

function TurnlightOn(nr : int)
{
	if(nr == lightNr)
	{
		isOn = true;
		light.intensity = OnLight;
	}
}

function TurnlightOff(nr : int)
{
	if(nr == lightNr)
	{
		isOn = false;
		light.intensity = OffLight; 
	}
}

¨

I hope someone can put some light in my dark why this is not working.

Thanks alot for using your time on reading my question.

That’s a little javascript trap you got here. As you don’t need to write everything, you don’t see that everything you write is part of a class inheriting from MonoBehaviour, which inherit from Component. Component have a property called light, without majuscule, which return GetComponent(Light). By calling your variable light, Unity is lost between your variable and Component’s property. Give it another name and you’ll be fine.