How to make toggable flashlight flicker only when on

Ok I’ve looked all over for a code to do this and I’ve been experimenting but nothing will work. So this is the script for the toggable flashlight:
var flashlight : Component;
var FlashLIghtOn : AudioClip;
var FlashLIghtOff : AudioClip;

    function Start () {
     
    flashlight = GetComponent("Light");
     
    }
     
    function Update () {
     
    if (Input.GetMouseButtonDown(0)) {
    if (flashlight.enabled) {
    flashlight.enabled = false;
    audio.PlayOneShot(FlashLIghtOn);
     
    }
    else {
    flashlight.enabled = true;
    audio.PlayOneShot(FlashLIghtOff);
     
     
    }
    }
    }

and I want it to flicker only when its on. Any help? Heres my flickering light script if it helps:
var flickerSpeed : float = 0.07;

private var randomizer : int = 0;

while (true) { 
    
    if (randomizer == 0) { 
        
        light.enabled = false; 
        
    } 
    
    else light.enabled = true; 
    
    randomizer = Random.Range (0.1, 3.5);

yield WaitForSeconds (flickerSpeed);

}

Sorry I suck at code right now… Still learning

It seems like the randomizer variable will never return 0. The range is 0.1 to 3.5, so it will never go below zero. Even if you fix that, it is extremely unlikely that it will become exactly zero randomly.

Try something like this -

public var flashlight : GameObject;
private var notFlickering : boolean = true;

function Update () {
	if (notFlickering)
		StartCoroutine(Flicker());
}

function Flicker() {
	notFlickering = false;
	var light : Light = flashlight.GetComponent("Light");

	var flickerChance : float = 0.8f;
	var flicker : boolean = false;
	if (Random.value < 0.8)
		flicker = true;

	var randomTime : float = 0;
	if (flicker){
		light.enabled = false;
		randomTime = Random.Range (0f, 0.1f);
	} else {
		light.enabled = true; 
		randomTime = Random.Range (0.5f, 3.5f);
	}

	yield WaitForSeconds(randomTime);

	notFlickering = true;
}