Creating Triggers that Que a sound to play once then destroy

First off I want to say thank you to any that read and reply and can help me with this. With that said…a description is in order. I have created a cube that you cannot see that the fps controller can walk through. I clicked “Is a Trigger” on the cube. Then i dropped in this code.

private var audioplayingalready : boolean = false;
private var audiotimer : float = 0.0;
private var currenttriggeritem : GameObject;
var audioplaytime : float = 10.0;

var Audio : AudioClip;
function Update () {
if(audioplayingalready){
     audiotimer += Time.deltaTime;
	 
	 if(audiotimer > 10){
	StopAudio();
	audiotimer = 0.0;
	}
	}



}

function OnControllerColliderHit (hit : ControllerColliderHit){ 
if (hit.gameObject.tag == "cube"  audioplayingalready == false){
  PlayAudio();
  }
  }
  function PlayAudio(){ audio.PlayOneShot(Audio);
  audioplayingalready = true;
  
  }
   function StopAudio(){
   audioplayingalready = false;
   }

Now I scrounged the forums and found a few similar script questions and even scourged my Unity book i bought. None of them have a “For Complete Dummies” answer.

What the script does do tho when attached to my cube trigger is make it so you can drag a audio clip into the Inspector…and has a audio play time area.

Basically i want to make it so when player walks into invisible cube trigger…it plays my sound…the whole 10 seconds of it or whatever it may be…and then will not play again after character has triggered it once.

so far…cant even get it to play a sound…

Like I said thank you to all and any who can help me with this with a “For Total Idiots” answer.

Wow…moment of clarity and I got it working :open_mouth:

This was my first script ive ever done and ever had work or do something i wanted…im stoked…here it is finished for my purposes

private var audioplayingalready : boolean = false;
private var audiotimer : float = 0.0;
private var currenttriggeritem : GameObject;
var audioplaytime : float = 10.0;

var Audio : AudioClip;
function Update () {
if(audioplayingalready){
     audiotimer += Time.deltaTime;
	 
	 if(audiotimer > 10){
	StopAudio();
	audiotimer = 0.0;
	}
	}



}

function OnControllerColliderHit (hit : ControllerColliderHit){ 
if (hit.gameObject.tag == "hiddenTrigger"  audioplayingalready == false){
  PlayAudio();
  }
  }
  function PlayAudio(){
     audio.PlayOneShot(Audio);
	audioplayingalready = true;
  
  }
   function StopAudio(){
   audio.PlayOneShot(Audio);
   audioplayingalready = false;
   }
   
   @script RequireComponent (AudioSource)

Why its not work for me? I must drag it to trigger with tag “hiddenTrigger” or what? Audio wont playing…