want to click n object to turn audio off

so in my scene there is a iHome and music is playing on it i want to be able to click it with the mouse and the music shuts off.

heres the code i got so far that is not working

var Ihome : GameObject;
var sound1 : AudioClip;

Function OnMouseDown(){
Ihome.AudioClip (sound1);
Ihome.audio.Stop(sound1);
}

plz help

2 Answers

2

If you just want to click the object to stop the sound, all you need is the code below - but this script must be assigned to the object which is playing the sound (the one which has the AudioSource):

function OnMouseDown(){
    audio.Stop();
}

Holy shit it works thanks man!