(stop sound) What's the problem in this code?

var soundon : AudioClip;
var soundoff : AudioClip;

function OnTriggerEnter () {

GetComponent.<AudioSource>().PlayOneShot(soundon);
GetComponent.<AudioSource>().audio.Stop(soundoff);
this.GetComponent.<Collider>().enabled = false;
}

the second sound (soundoff) not appears, the code works except this lines

-var soundoff : AudioClip;
-GetComponent.().audio.Stop(soundoff);

where is the fail?

.Audio.Stop?

-GetComponent.()audio.Stop(soundoff);

thats okay now?

I looked up the scripting API. Their example declares var audio: AudiSource = GetComponent.();
From there you can just run audio.Stop();

how can i add the second soundoff correctly? when the player enter the trigger, play a music and stop other…

2220424--147796--stopsound.png

seems solved

GetComponent.().soundoff.Stop();

I think some good tutorials for javascript should help you. This is exactly what I said in my post to you. :stuck_out_tongue: