hey here wesley again sound for my gun

hey can somebody help me out please? here is the problem i want to fire my gun (that works)But i want also at the same moment to play the gun firesound this is my script

What did i do wrong?

function Update() { if( Input.GetButtonDown( "Fire1" ) ){ audio.play("p90"); } } }

and do i need to attach the script to the buller or to the p90 gun

the guns are named p90 the gun fire sound is named p90.mp3

tanks by the way greats wesley

First you need an AudioSource component on the gameobject. (otherwise audio is null) You can assign an AudioClip to the AudioSource in the editor.

audio.Play() doesn't take a string argument. you can specify at which sample the clip should start playing (or omit the parameter to play from start)

[...]
{
   audio.Play();

You can also set a different clip by assigning an audioClip-reference to audio.clip

var P90Sound : AudioClip;
[...]
{
   audio.clip = P90Sound;
   audio.Play();

or Play the sound as OneShot:

var P90Sound : AudioClip;
[...]
{
   audio.PlayOneShot(P90Sound);