audio clip isn't playing properly.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ThunderClap : MonoBehaviour {

bool canFlicker = true;
public AudioClip clip;
AudioSource audio;

Light li;

void Awake()
{
	li = GetComponent<Light> ();
	audio = GetComponent<AudioSource> ();
}

void Update()
{
	StartCoroutine (Flicker ());
}

IEnumerator Flicker()
{
	canFlicker = false;
	audio.PlayOneShot (clip);
	li.enabled = true;
	yield return new WaitForSeconds (Random.Range (0.2f, 0.8f));
	li.enabled = false;
	yield return new WaitForSeconds (Random.Range (1, 5));

	canFlicker = true;
}

}

What do you mean by it isn’t playing properly? is it not playing at all or is the audio it is playing sounding wrong?

You might be able to fix this by using AudioSource.PlayClipAtPoint(audio, Vector2.zero);

So your Code would be:

public class ThunderClap : MonoBehaviour {
bool canFlicker = true;
     public AudioClip clip;
     // AudioSource audio; <-- This line is no longer Needed
     Light li;
     void Awake()
     {
         li = GetComponent<Light> ();
     //    audio = GetComponent<AudioSource> (); <-- Nor this Line
     }
     void Update()
     {
         StartCoroutine (Flicker ());
     }
     IEnumerator Flicker()
     {
         canFlicker = false;
         AudioSource.PlayClipAtPoint(clip, Vector2.zero); // Play AudioClip "clip" at the exact position of the object
         li.enabled = true;
         yield return new WaitForSeconds (Random.Range (0.2f, 0.8f));
         li.enabled = false;
         yield return new WaitForSeconds (Random.Range (1, 5));
         canFlicker = true;
     }

Hello! I copy this code because I had the same problem in the same exercice but the ThunderClap is not triggering. So, I am not hearing a thing! Could some of you help me?

Thanks!