Hello, I have a Bolt-Action Sniper Rifle and i have this script attached to it:
var isReloading = false;
function Update ()
{
Screen.lockCursor = true;
if(Input.GetAxis("Fire1"))
{
if(isReloading == false)
{
audio.Play();
Reload();
}
}
}
function Reload()
{
animation.Play("reload");
if(!animation.isPlaying)
{
isReloading = true;
}
else
{
isReloading = false;
}
}
Its supossed to play a gun shot sound when pressing the Left Mouse Button (Fire1), but i dont want to play that sound when playing the “reload” animation, but it doesn’t seem to work.
Can someone please tell me what im doing wrong?
Thank You! :razz:
I’m sure you wanted to use GetButtonDown for fire, get axis is for axises (sticks - mouse movement)
Also depending on if you want reload to ever get a sound, consider using PlayOneShot so fire can continue to play when you kick of the reload audio 
oh, so there is why the gunshot sound plays lots of times when clicking once the mouse button… hehe Thank u for that… 
here is my code now:
var isReloading = false;
var Clip : AudioClip;
function Update ()
{
Screen.lockCursor = true;
if(Input.GetButtonDown("Fire1"))
{
if(isReloading == false)
{
audio.PlayOneShot(Clip);
Reload();
}
}
}
function Reload()
{
animation.Play("reload");
if(!animation.isPlaying)
{
isReloading = true;
}
else
{
isReloading = false;
}
}
it still play the gunshot sound when reloading 
Forget it i have figured it out:
var CanShot = true;
var Shot : AudioClip;
var ReloadS : AudioClip;
function Update ()
{
Screen.lockCursor = true;
if(Input.GetButtonDown("Fire1"))
{
if(CanShot)
{
if(!animation.isPlaying)
{
audio.PlayOneShot(Shot);
CanShot = false;
}
}
}
if(Input.GetButtonDown("Reload"))
{
Reload();
CanShot = true;
}
}
function Reload()
{
animation.Play("reload");
audio.PlayOneShot(ReloadS);
}