Help with thunder script

Hey, I’m new to Unity, and this will be my first post.

Anyway, I tried to make a automatic thunder script, like, you walk around in a house and all of a sudden thunder sound starts playing and the directional light increases it’s intensity.
I have the sound and obviously the directional light, but I don’t know how to make the light flicker.

I’m not very good with explaining but here’s how my script looks like so far:

using UnityEngine;
using System.Collections;

public class thunder : MonoBehaviour {
	
	public float intens = 1.02f;
	public int ThunderRate = 100;
	public int ThunderRateRandom;
	public bool on = false;
	
	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	public void Update () {
		ThunderRateRandom = Random.Range (0, ThunderRate + 1);
		if(ThunderRateRandom == ThunderRate)
		{
			if(!on)
			{
			on = true;
			light.intensity = intens;
			audio.Play();
			}
			else
			{
				Update ();
			}			
		}		
	}	
}

I know that this script sucks ass but I’m very new to this stuff.
If anyone mind poiting me in the right direction on making the light flicker, it would be lovely :3

Thank you for reading.

I did this for a school project. You can use a coroutine to time the thunder flicker.

My thunder needed to trigger over network so was a bit more complicated but i think you get the idea. :wink:

[RPC]
    void NetworksThunder()
    {
        StartCoroutine(ThunderHandler());
    }

    IEnumerator ThunderHandler()
    {
        yield return new WaitForSeconds(20F);
        
        audio.Play();
        light.intensity = 0.8F;
        yield return new WaitForSeconds(0.3F);
        light.intensity = 0.0F;
        yield return new WaitForSeconds(0.2F);
        light.intensity = 0.6F;
        yield return new WaitForSeconds(0.2F);
        light.intensity = 0.0F;
        if (PhotonNetwork.isMasterClient)
        {
            float random = Random.Range(20F, 40F);
            yield return new WaitForSeconds(random);
            photonView.RPC("NetworksThunder", PhotonTargets.All);
        }
    }

Thank you BFGames! it works perfectly now.