I feel like I should know this I’m just drawing a blank.
I have a MonoSingleton script for the items in my game and I’m referencing the item script from another script when the player wants to use the item… but I need it to not give the item if the player has none left
Here is an example of the code I have:
public void UseGoggles()
{
if (Goggles <= 0)
Debug.LogWarning("None Left!");
if (Goggles >= 1)
Goggles -= 1;
SaveSystem.SaveItems(this);
}
This is from the item script
public void GiveGoggles()
{
goggles.SetActive(true);
Items.Instance.UseGoggles();
}
This is the code referencing the item script… I know there is a simple way to have it not set them as active if the item count is 0… any help is greatly appreciated!
I should have been more clear I apologize… the script referencing the items script is what is called from the “OnValueChange” in the inspector on the toggle… so when the player clicks the toggle it is supposed to give them the item, but the way I have it coded the item is given no matter what the number is.