Toggling a purchased gameobject on and off in inventory

I am trying to do some in game character customization and I’m running into a big problem. I have a game object the user wants to buy/equip (lets call it helmet) in the shop, the user goes to the shop and if they have enough coins they buy the helmet and i run this code:

if (frogHelmetSold == 1)

{

frogHelmet.SetActive (true);

frogHelmetLocker.SetActive (true);

}

else

{

frogHelmet.SetActive (false);

frogHelmetLocker.SetActive (false);

}

This will purchase the helmet, equip it and put it in the users locker and is working fine. BUT when i try to toggle the helmet on and off with the frogHelmetLocker button, like this:

public void toggleFrogHelmet()

{

frogHelmet.SetActive (!frogHelmet.activeSelf);

}

When debugging the value for activeSelf is always false. Which at least should mean the Helmet turns off but it doesn’t.

edit: frogHelmetSold must be an int so i can use PlayerPrefs

It might be your frogHelmetSold variable, if it is not equal to 1 than frogHelmet will always be false. If you can only buy the helmet once you could make it a bool than you could go: frogHelmet.SetActive (frogHelmetSold); frogHelmetLocker.SetActive (frogHelmetSold); instead of having ifs.