Public variable not updating

My problem is that even thought the value of money is updating in it’s own function, the value of money will stay zero in the “if (cB == true)” function, I have tried many suggested solutions but the value of money still won’t update. I’m probably missing something obvious since I’m still new, any help is welcomed, thanks in advance.

public class moneyV2 : MonoBehaviour
    {
        public bool cB;
        public bool cCB;
        public bool sCB;
        public bool mB;

    public int money;
    public int cN;
    public int cCN;
    public int sCN;
    void start ()
    {
        cN = 1;
    }
    public void OnMouseDown ()
    {
        if (cB == true)
        {
            Debug.LogFormat("money = {0}", money);
            if (money >= 10)
            {
                buyCow();
            }
            else
            {
                Debug.Log("money < 10");
            }
        }
        if (mB == true)
        {
            money += cN;
            Debug.LogFormat("money = {0}", money);
            
        }
    }
    public void buyCow ()
    {
        money = money - 10;
        cN++;
        Debug.LogFormat("cN = {0}", cN);

Well, it’s not really clear why you mentioned your “cB” variable as the code related to it won’t increase money, just decrease it when you buy something. You could potentially increase money when mB is true. However your actual issue is most likely that cN is zero so you never gain any money. Why cN is zero? Because you named your “Start” method “start” so it won’t be called at all, at least not by Unity. The method has to start with a capital letter.

Apart from that you really should work on giving your variables descriptive names. Sorry but cB, cCB, sCB, mB, cN, cCN, sCN makes absolutely no sense. Why don’t you use some chinese characters or emojis that would make it even harder to understand anything :slight_smile: