sound on button press

I have a sound which works fine when it is set as the audio source of the whole level, but i want it to play only when I press a button so I have a simple script like this

var MySound : AudioSource;
  function update(){  
    if(Input.GetButton("Jump")){
       MySound.Play();
    }}

but it does not work for some reason.

You have to put your code in a function, in this case Update:

var mySound : AudioSource;

function Update () {
   if(Input.GetButtonDown("Jump")){
      mySound.Play();
   }
}

Also it should be GetButtonDown because GetButton returns true every frame you call it.

//This is where you are going to drag your adio onto…

var MyAudio: AudioClip;

function OnGUI (){

    if (GUI.Button((0,0,0,0), "Bla Bla", MenuStyle)){
      audio.PlayOneShot(MyAudio);
    }

}

or just
audio.Play(MyAudio)

Void Update ()

If (Input.GetMouseButtonDown(“Jump”)

mysound.play()