Play a sound when flicker?

Basically, I’m making a Horror Game…

I made a spotlight script so the light flickers. But it is possible to play maybe two randomized sounds when It’s flickering? (Like you see in many horror games)

Thanks!

Usually you should have an array of AudioClip, populate it in the Inspector with the desired sounds, and randomly select and play one of them when needed:

var sounds: AudioClip[]; // set the size and assign the sounds in the Inspector

function RandSound(){
  audio.PlayOneShot(sounds[Random.Range(0, sounds.length)]);
}

This code may be part of the spotlight script, and you must add an AudioSource to the spotlight. When needed, call RandSound() and a randomly selected sound of the sounds array will be played.