Making a sound play only once with a Boolean variable in javascript

I’m very new to coding, and I’m having problems setting my code to play only on the first collision with the box collider.

Here’s the code so far.

var Sound : AudioClip;

audio.loop = false;

function OnTriggerEnter(){
audio.PlayOneShot(Sound);
}

I’ve been told to set the variable as a boolean that sets it to play only on the initial collision, but all the help that’s available online is concerning things logging in, rather than this.

Any help would be wholeyl appreciated, thanks very much

As being said, add a boolean to test against.

private var hasPlayed : boolean = false;

function OnTriggerEnter() {
    if(!hasPlayed) {
        audio.PlayOneShot(Sound);
        hasPlayed = true;  
    }
}