Help with flashlight script.

I was making a code to make a toggable flashlight. this is what i did and this is the error i got.

Assets/Scripts/Flashlight.js(1,1): BCE0044: expecting EOF, found ‘on’.

here is my script

on : boolean = false; //this is the line it said
 
function Update()
{
    if(Input.GetKeyDown(KeyCode.F))
        on = !on;
    if(on)
        light.enabled = true;
    if(!on)
        light.enabled = false;
}

var on : boolean = false;

It seems you’ve missed a var part of your variable definition

Works just fine… don’t know much about JavaScript though lol

var flashOn = false;

function Update () 
{
	if(Input.GetKeyDown(KeyCode.F))
	   flashOn = !flashOn;
	
	if(flashOn)
		light.enabled = true;
	else if(!flashOn)
		light.enabled = false;
}