Checking ig light is on and if yes disable script.

Hey, again.

I got this script which disables a light with LMB. It was made by Eric5h5 in my other question here. I’m trying to now disable a script when the torch is off. The script goes like this.

#pragma strict

var lightState = Light;

function Update () 
{
	if (Input.GetButtonDown("Fire1")) 
	{
		GetComponent(Light).enabled = !GetComponent(Light).enabled;
	}
	if (!lightState)
	{
	
	}
}

I tried doing

if(GetComponent(Light).enabled == true)

None of them work.

I think this is a better solucion for you: SetActive answer from Berenger