Play audio on instantiate

I need help with this shoot script i want it to play the audio when i shoot ( like the gun sound when it is fired) Of course it may be obvious to yall what the problem is for two reasons but 5 6 reasons for so I decided to just post it

var Snowball:Rigidbody;
var shootForce = 1000;
var MyAudioClip : AudioClip;

function Update () 
   	     AudioSource.PlayOneShot(MyAudioClip, transform.position ); 
	var instanceBullet = Instantiate (Snowball, transform.position,
    instanceBullet.rigidbody.AddForce(transform.position + transform.forward * shootForce);

Any help at all needed. And thanks ahead of time (even if its a no brainer at least i’m trying and i appreciate).


With properly formatted code, the problem becomes much more obvious. Your bracketing is in the wrong spot: you’re only affecting PlayOneShot with that if statement, nothing else.