Why wont my fire audio work?


I have a simple gun animation that plays when it is fired. I have tried to attach a sound to it but it doesn't want to play. I thought the code below would make the sound play when I fired, but it doesn't!

EDIT : I have sorted it out, however I only want the audio to play once, and then not be able to play again until the animation is finished. How would I do this?

var rifle : AudioClip; 

function Update () {

if (Input.GetButton("Fire1")) {



Maybe you don't have an audio listener, or maybe the source is too far from the listener.

Is your audio file path correct? Does it gives any error on the console?