Animation interference problem

I have wrote this script that plays my animations to what keys and buttons are being held down, I have recently added in the walk left and right animations. They do not play when A or D is pressed where as if I put it into a different script and take off the script that has the shooting animations on it works fine. What’s going wrong and how can I fix this?

function Start () {
    animation["walk_left"].speed = 1.5;
    animation["walk_right"].speed = 1.5;
    animation["walk_left"].wrapMode = WrapMode.Loop;
    animation["walk_right"].wrapMode = WrapMode.Loop;
    animation["idle"].speed = 0.5;
    animation["walk"].speed = 2.5;
    animation["reload"].speed = 1.5;
    animation["shoot"].speed = 6;
    animation["idle"].wrapMode = WrapMode.Loop;
    animation["walk"].wrapMode = WrapMode.Loop;
    animation["shoot"].wrapMode = WrapMode.Once;
    animation["reload"].wrapMode = WrapMode.Once;
    animation["shoot"].layer = 1;
    animation["reload"].layer = 2;
    animation.Stop();
}

var fullClip : int = 8 ;
var bulletsLeft : int = 8 ;

function Update () {
    if(Mathf.Abs(Input.GetAxis("Vertical")) > 0.1)
        animation.CrossFade("walk");
    else
        animation.CrossFade("idle");
    
    if(Input.GetKeyDown("a")){
        animation.CrossFade("walk_left");
    }
    
    if(Input.GetKeyDown("d")){
        animation.CrossFade("walk_right");
    }
    
    if(Input.GetButtonDown("Fire1")){
        if(bulletsLeft > 0 ){
            bulletsLeft -- ;
            animation.Stop();
            animation.Play("shoot");
        }
    }
    
    if(Input.GetButtonDown("r")){
        animation.Stop();
        animation.CrossFade("reload");
        bulletsLeft = fullClip ;
    }
}

So (per the comments above) @Dreave would like the idle to be playing when nothing else is.

To do that you can put the animations on different layers - the higher the number the more important the priority. I can see you have already got that for reload and shoot. Make each of those +1 and make your walk animations = 1 then leave idle on 0. Start playing it in Start and when nothing else is playing it will be shown.

Firstly you shouldn’t need those animation.Stop() calls as the layers should override the other animations so drop them.

Now your problem then is that you want to turn on and off the walk animations.

You could .enable all of your walk animations in Start and set the weight to 0. E.g.

animation["walk_left"].enabled = true;
animation["walk_left"].weight = 0;

The instead of

if(Input.GetKeyDown("a")){
    animation.CrossFade("walk_left");
}

You could do

if(Input.GetKeyDown("a")){
    animation.Blend("walk_left",1);
} else {
    animation.Blend("walk_left", 0);
}

And the same for walk right.