Play Sound when GUI button is pressed.

Hello, I am trying to have a quick sound play when I press a GUI Button Here is the script that I have for the GUI buttons. Is there an easy way to attach a sound to each button.

var model : GameObject;

function OnGUI () { 

  //background box 
  GUI.Box (Rect (10,130,100,90), "Sounds");

  //Make first button
  if (GUI.Button (Rect(20,160,80,20),  "Go")){

  } 

  //Make second button
  if (GUI.Button (Rect(20,190,80,20),  "Stop")){ 

  } 
}

It is in fact very simple: All you need to do is attach an AudioSource to the same game object (or any other game object), provide a "slot" for that audio source, e.g.

var audio : AudioSource;

And then call

audio.PlayOneShot(audio.clip);

in your if-blocks. If you want multiple sounds, simply create one game object with relevant audiosources attached for each sound you want to play (and create var audio1 : AudioSource; and so on, or use names that actually will tell you what the sound means).

var model : GameObject;
var track : AudioSource;

function OnGUI () { 

  //background box 
  GUI.Box (Rect (10,130,100,90), "Sounds");

  //Make first button
  if (GUI.Button (Rect(20,160,80,20),  "Go")){
   audio.clip = track;
        audio.loop = false;

      audio.Play();

  } 

  //Make second button
  if (GUI.Button (Rect(20,190,80,20),  "Stop")){ 

      audio.Stop();

  } 
}

uhm really thanks but... i got a error and i dont know what to do can you help me ?

Assets/side-scroller/Scripts/GUI Options Button.js(40,25): BCE0022: Cannot convert 'UnityEngine.AudioSource' to 'UnityEngine.AudioClip'

what to do ?

var track : AudioClip;

AudioClip click;

if (GUI.Button(new Rect(posX, posY, alto, ancho), “Foto”))
{
StartCoroutine(ScreenShotManual());
//Application.Quit();
//GetComponent().PlayOneShot(click);
GetComponent().Play();
//audio.clip = track;
//audio.Play();

	}

Simply attach this script to your button and provide an audio clip. (This is a PLUG & PLAY component)

using UnityEngine;
using UnityEngine.UI;

public class ButtonTapSound : MonoBehaviour
{
	[SerializeField] AudioClip _audioClip;
	[SerializeField] [Range(0.0f, 1.0f)] float _volume = 1;
	AudioSource _audioSource;

	void Awake ()
	{
		_audioSource = gameObject.AddComponent<AudioSource> ();
		if (_audioClip != null)
			_audioSource.clip = _audioClip;
		_audioSource.playOnAwake = false;
		_audioSource.volume = _volume;
		GetComponent<Button> ().onClick.AddListener (() => _audioSource.Play ());
	}
}

uhmm got a little problem where to place the audio.PlayOneShot(audio.clip); ??? please help this sad guest