How to prevent a variable used in two functions from being overridden? [SOLVED]

So I’m trying to develop a fighting game and I 've come at a bit of an issue. I’m trying to assign different values to a variable depending on the button being pressed. ` if (Input.GetKey(KeyCode.D))
{
MovingState = 1;
}
else
{
MovingState = 0;
}

   if (Input.GetKey(KeyCode.A))
    {
        MovingState = 2;
    }
    else
    {
        MovingState = 0;
    }`

When I press D I want “MovingState” to equal 1, and when I press A, I want it to equal 2. The problem is that for whatever reason, I can never get “MovingState” to equal 1 when both inputs are being read. When I remove the A input function however, I can get it to equal 1, no problem. I believe that the A input is overriding the D input, but I’m not sure how.

Maybe you can try to do something like that:
if (Input.GetKey(KeyCode.D))
{
MovingState = 1;
}
else if (Input.GetKey(KeyCode.A))
{
MovingState = 2;
}
else
{
MovingState = 0;
}