Comparing strings returning false when they're the same

string TextureForWeapon = Weapon + "_" + CurrentCombo;
print(TextureForWeapon);

// returns Steel Sword_1

 if (TextureForWeapon == "Steel Sword_1") {
       print ("it matches");
 }

No idea what’s going on here. TextureForWeapon should be “Steel Sword_1” and that’s what it’s outputting, but when I compare it - it returns false, even though they’re identical.

I narrowed down the problem. It’s because the “Weapon” variable was pulled from a split string. Strangely, the CurrentCombo (an int), which was also pulled from a split string works just fine

Maybe there’s a trailing space or some other character from the split. Try:

string TextureForWeapon = Weapon.Trim() + "_" + CurrentCombo;

Debug.LogFormat("[{0}]", TextureForWeapon);