Simple On/Off script not working(Solved)

Guys Im having probs with my On/Off script. In a nutshell its a script to turn a Flashlight (spotlight) on and off. The problem is it will only turn off and not back on again ! ?

var FlashlightLight : Light;
var LaserPointerLight : Light;

var FlashlightOn : boolean = true;
var LaserPointerOn : boolean = true;


function Update ()
{
	var AlreadyChecked : boolean = false;
	
	if(Input.GetButtonDown("Flashlight"))
	{
		if(FlashlightOn)
			FlashlightOn = false;
			AlreadyChecked = true;
		if(!FlashlightOn && !AlreadyChecked)
			FlashlightOn = true;
	}
	
	FlashlightLight.enabled = FlashlightOn;

}

Now Im asuming everything is connected up correctly, else I wouldnt be able to turn the light off.

Any suggestions ?

Try restructuring your update function like so:

function Update()
{
    if(Input.GetButtonUp("Flashlight"))
    {
         FlashlightOn = !FlashlightOn;
    }

    FlashlightLight.enabled = FlashlightOn;
}

Im not sure what you are using AlreadyChecked for so this is a simple answer.

What is this AlreadyChecked variable for? If the FlashlightOn is true when the button is pressed, AlreadyCheck is set to true, therefore the second if statement can never be true afterward.

if(!FlashlightOn && !AlreadyChecked)

I don’t understand it’s purpose so I would simple remove the second condition and replace it with an else if.

Thanks guys ! Strangely somebody already sent me some code that is pretty much exactly like what you guys have suggested. Looking at it now the code Im using (from a tutorial) is way over complicated for what it should be…lol