photocamera flash

hello i have a script for a photo flash. But the script is not good. here is the script:

sec : float = 0.1f;

function update () {

      
//if pressed mouse1 the light will go on for 0.1 second and then go off
if (Input.GetKeyDown(mouse1));

     light.intensity = "1.0";

     yield.WaitForSeconds = sec;

     light.intensity = "0.0";

can anyone help me?

You can’t have yield wait for secs in the update loop.

Instead make a function on it’s own, put the light code you did in there, and call that function under the if statement.

ALSO and this is a bigger issue, you have a “;” after the if statement. Take it off. Also, because you didnt’ use { } at the if statement, only the first line after it is called if the statement is checked. the rest will run anyway. The check should be GetMouseBtnDown()

Code should be

function Update(){
   if (Input.GetMouseButtonDown(0)){
      LightMe();
   }
}
        
function LightMe(){
   light.intensity = 1.0;
   yield WaitForSeconds(sec);
   light.intensity = 0.0;
}

Changed stuff from @tanoshimi