Second IF statement won't run?

I am not sure why my code is not running the second IF statement in the list if the first is not true. I have a variable that is an enum that I am trying to check. If it is one value, then run the first IF statement, if its the next value then run the second. The first one works perfectly but when I change the enum variable to the second value it never gets to the second IF statement. Why is this? How do I fix it?

 public void AddAttacks(Item item)
    {
        if (item.itemType == Item.ItemType.MainHand)
        {
            if (item.attack1 != null)
            {
                MainHandAttacks.Add(item.attack1);
                GameObject attack1 = Instantiate(attackSlot, mainHandPanel.transform);
                attack1.GetComponentInChildren<Text>().text = item.attack1.name;
                attack1.GetComponent<AttackSlot>().attack = item.attack1;

                attack1.GetComponent<AttackSlot>().SelectAttack();
             }
        }

        if (item.itemType == Item.ItemType.OffHand)
        {
            if (item.attack1 != null)
            {
                OffHandAttacks.Add(item.attack1);
                GameObject attack1 = Instantiate(attackSlot, offHandPanel.transform);
                attack1.GetComponentInChildren<Text>().text = item.attack1.name;
                attack1.GetComponent<AttackSlot>().attack = item.attack1;
            }
      }
}

from what I can see, if the first IF statement is true then it should move down to the next one and check. I have also tried setting it to an ELSE IF statement and that doesn’t change it at all. Any ideas?

As you have it now, both ifs will run a check, even if the first is true, the second if will check if it’s an offhand as well.

That being said, you should insert print/Debug.log statements in at points where you think it should be hitting and print out values to make sure you have the expected values.

hm, it seems like if it is running both then it should be working. Not sure why it would be hanging up.

I actually already inserted lots of debugs earlier, that’s how I found out the second IF statement isn’t running at all. Still no clue why

So when Item.ItemType was an OffHand, (your debug.log showed this) and you had additional debugs within the offhand if statements, they never showed up?

actually if I set it to OffHand I never got any debug.logs, no matter where they were inside that IF statement. It just never runs and I have no idea why

How are you calling AddAttacks?

And that was the problem. Where I was calling AddAttacks I was not calling it for the slot for the offhand, only for the main hand. Thanks for the help!

No problem. Glad you got it working!