light switch

i have a torch with a point light attached and i use this script for turning it on and off:

function Update() {

if (Input.GetKeyDown(“mouse 0”)) {

if (light.enabled == true)

	light.enabled = false;

	else

	light.enabled = true;

}

}

For a fire effect i added a particle system but how do i make it that they both turn on when i press my left mousebutton and disapear when i release it?

Or just disapear when i press again.
Evantualy i need both so i hope that you could help me.

this should work , choose if the game opject have a light component or a particle emmeter or both by chick them

var lightOk = true;

var particleEmitterOk = true;

function Update()

{

if (Input.GetKey("mouse 0")) 

{

	if(lightOk)

	{

	light.enabled = true;

	}

	if(particleEmitterOk)

	{

	particleEmitter.emit = true;

	}

}

else

{

	if(lightOk)

	{

	light.enabled = false;

	}

	if(particleEmitterOk)

	{

	particleEmitter.emit = false;

	}

}

}

Try this

function Update() {

if (Input.GetKeyDown(“mouse 0”)) {

if (light.enabled == true)

light.enabled = false;
particleEmitter.emit = false;

else

light.enabled = true;
particleEmitter.emit = true;

}
}

sry but it doesn’t work it gives me errors that say:

Assets/ParticleSwitch.js(11,1): BCE0044: expecting }, found ‘else’.

and:

Assets/ParticleSwitch.js(15,3): BCE0044: expecting EOF, found ‘}’.

so i can’t play it is there a solution to these errors?
maybe some mistakes in the script??

it works sort of if you put it like this:

function Update()

{

if (Input.GetKeyDown(“mouse 0”))

{

if (light.enabled == true)

{

light.enabled = false;

particleEmitter.emit = false;

}

else

{

light.enabled = true;

particleEmitter.emit = true;

}
}}

but then still when i attach it to the torch object it says there is no Light attached to it.

only if i put it on the light itself it works but not exactly how i would like it becouse it turns on when i click and off when i click again and i would like that if i release my mouse it turns off.

and the script wont do anything with my particles is that becouse i use a particle system?

becouse when i put the script on that to nothing still happens so did i do something wrong??

oh yeh im putting the story im working on of the game up on deviantart tomorrow i think.

i hope im not bothering since im realy bad at scripting myself and this is my first real game i try.

and if you’re wondering why i want the mouse button like that is becouse the torch is more of a fire staff.