Flashing light not working

Hello
I have some problem with a simple script
I couldnt use yield WaitForSeconds(); in an awake function,
so I made a seperate function, I suspect it´s something wrong about how I have built this up.

var ljus : Light;
var blinka : boolean = true;
var frekvens : float;
function Awake(){
	Blinka();
}	

function Blinka () {
		while (blinka){
		ljus.enabled = false;
		yield WaitForSeconds(frekvens);
		ljus.enabled = true;
		}

}

Does it stay permanently off now?

You didn’t say what the problem actually was but I’m guessing, as Acid did, that the light stays off all the time. The reason is, you enable it then immediately disable it again before waiting. Add a second yield WaitForSeconds after enabled = true, so the light will spend some time switched on before switching off again.

it actually stays on all the time, and adding a secon yield WaitForSeconds didnt do anything, so i´m kinda confused.
thanks for your time though.

ok I solved it I added a second yield, and I guess it had disabled the blinka in the inspector, cant remember doing that though but it works now so thank you so much.

lol, code doesn’t tend to work very well if it isn’t running :slight_smile: