AnimationMy animation keeps moving even though my script says to play animation when shoot.

var BulletSpawn : Transform;
var Bullet : GameObject;
var Ammo = 10;
function Start () {

}

function Update () {
if(Input.GetButtonDown(“Fire1”)){
animation.Play();
Instantiate(Bullet ,BulletSpawn.transform.position , BulletSpawn.transform.rotation);
Ammo --;
}
}

function OnGUI() {
GUI.Label(Rect (10, 10, 100, 20), "Ammo : " + Ammo);

I’m guessing that you’re not using the animator and you didnt set your animation wrapmode so in the start method just simply add this :

 animation.WrapMode = WrapMode.once;

For more informations visit the documentation:

https://docs.unity3d.com/Documentation/ScriptReference/Animation-wrapMode.html