2 ints are not getting added

I am making an idle game and 2 values are not getting added when im testing. The issue is with productionUpgrade2Level, it is not getting added to coinsPerSecond. Even though productionUpgrade1Level is. They share the exact same code as you will see below. The methods are being activated with the on click function with a button.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ClickScript : MonoBehaviour
{
    public Text coinsText;
    public Text coinsPerSecondText;
    public Text clickUpgrade1Text;
    public Text productionUpgrade1Text;
    public Text coinsClickValueText;
    public Text clickUpgrade2Text;
    public Text productionUpgrade2Text;

    public double coins;
    public double coinsClickValue;

    public double coinsPerSecond;

    public double clickUpgrade1Cost;
    public int clickUpgrade1Level;

    public double productionUpgrade1Cost;
    public int productionUpgrade1Level;

    public double clickUpgrade2Cost;
    public int clickUpgrade2Level;

    public double productionUpgrade2Cost;
    public int productionUpgrade2Level;
    public double productionUpgrade2Power;

    public void Start()
    {
        Load();
    }

    public void Load()
    {
        coins = double.Parse(PlayerPrefs.GetString("Coins", "0"));
        coinsClickValue = double.Parse(PlayerPrefs.GetString("CoinsClickValue", "1"));
        clickUpgrade1Cost = double.Parse(PlayerPrefs.GetString("ClickUpgrade1Cost", "10"));
        clickUpgrade2Cost = double.Parse(PlayerPrefs.GetString("ClickUpgrade2Cost", "100"));
        productionUpgrade1Cost = double.Parse(PlayerPrefs.GetString("ProductionUpgrade1Cost", "25"));
        productionUpgrade2Cost = double.Parse(PlayerPrefs.GetString("ProductionUpgrade2Cost", "250"));
        productionUpgrade2Power = double.Parse(PlayerPrefs.GetString("ProductionUpgrade2Power", "5"));

        productionUpgrade2Level = PlayerPrefs.GetInt("ProductionUpgrade2Level", 0);
        productionUpgrade1Level = PlayerPrefs.GetInt("ProductionUpgrade1Level", 0);
        clickUpgrade1Level = PlayerPrefs.GetInt("ClickUpgrade1Level", 0);
        clickUpgrade2Level = PlayerPrefs.GetInt("ClickUpgrade2Level", 0);
    }

    public void Save()
    {
        PlayerPrefs.SetString("Coins", coins.ToString());
        PlayerPrefs.SetString("CoinsClickValue", coinsClickValue.ToString());
        PlayerPrefs.SetString("ClickUpgrade1Cost", clickUpgrade1Cost.ToString());
        PlayerPrefs.SetString("ClickUpgrade2Cost", clickUpgrade2Cost.ToString());
        PlayerPrefs.SetString("ProductionUpgrade1Cost", productionUpgrade1Cost.ToString());
        PlayerPrefs.SetString("ProductionUpgrade2Cost", productionUpgrade2Cost.ToString());
        PlayerPrefs.SetString("ProductionUpgrade2Power", productionUpgrade2Power.ToString());

        PlayerPrefs.SetInt("ProductionUpgrade1Level", productionUpgrade1Level);
        PlayerPrefs.SetInt("ProductionUpgrade2Level", productionUpgrade2Level);
        PlayerPrefs.SetInt("ClickUpgrade1Level", clickUpgrade1Level);
        PlayerPrefs.SetInt("ClickUpgrade2Level", clickUpgrade2Level);


        coins = double.Parse(PlayerPrefs.GetString("Coins", "0"));
        coinsClickValue = double.Parse(PlayerPrefs.GetString("CoinsClickValue", "1"));
        clickUpgrade1Cost = double.Parse(PlayerPrefs.GetString("ClickUpgrade1Cost", "10"));
        clickUpgrade2Cost = double.Parse(PlayerPrefs.GetString("ClickUpgrade2Cost", "100"));
        productionUpgrade1Cost = double.Parse(PlayerPrefs.GetString("ProductionUpgrade1Cost", "25"));
        productionUpgrade2Cost = double.Parse(PlayerPrefs.GetString("ProductionUpgrade2Cost", "250"));
        productionUpgrade2Power = double.Parse(PlayerPrefs.GetString("ProductionUpgrade2Power", "5"));

        productionUpgrade2Level = PlayerPrefs.GetInt("ProductionUpgrade2Level", 0);
        productionUpgrade1Level = PlayerPrefs.GetInt("ProductionUpgrade1Level", 0);
        clickUpgrade1Level = PlayerPrefs.GetInt("ClickUpgrade1Level", 0);
        clickUpgrade2Level = PlayerPrefs.GetInt("ClickUpgrade2Level", 0);
    }

    public void Update()
    {
        coinsPerSecond += productionUpgrade1Level + (productionUpgrade2Level * productionUpgrade2Power);
        

        coinsClickValueText.text = "Click

+" + coinsClickValue + " Coins";
coinsText.text = “Coins: " + coins.ToString(“F0”);
coinsPerSecond = productionUpgrade1Level;
coinsPerSecondText.text = coinsPerSecond + " coins/s”;

        clickUpgrade1Text.text = "Click Upgrade 1

Cost: " + clickUpgrade1Cost.ToString(“F0”) + "coins
+1 click
Level: " + clickUpgrade1Level;
clickUpgrade2Text.text = "Click Upgrade 2
Cost: " + clickUpgrade2Cost.ToString(“F0”) + "coins
+5 click
Level: " + clickUpgrade2Level;

        productionUpgrade1Text.text = "Production Upgrade 1

Cost: " + productionUpgrade1Cost.ToString(“F0”) + "coins
1 coins/s
Level: " + productionUpgrade1Level;
productionUpgrade2Text.text = "Production Upgrade 2
Cost: " + productionUpgrade2Cost.ToString(“F0”) + "coins

  • " + productionUpgrade2Power + " coins/s
    Level: " + productionUpgrade2Level;

          coins += coinsPerSecond * Time.deltaTime;
    
          Save();
      }
    
      public void OnClick()
      {
          coins += coinsClickValue;
      }
    
      public void BuyClickUpgrade1()
      {
          if (coins >= clickUpgrade1Cost)
          {
              clickUpgrade1Level++;
              coins -= clickUpgrade1Cost;
              clickUpgrade1Cost *= 1.07;
              coinsClickValue++;
          }
       
      }
    
      public void BuyClickUpgrade2()
      {
          if (coins >= clickUpgrade2Cost)
          {
              clickUpgrade2Level++;
              coins -= clickUpgrade2Cost;
              clickUpgrade2Cost *= 1.09;
              coinsClickValue += 5;
          }
    
      }
    
      public void BuyProductionUpgrade1()
      {
          if (coins >= productionUpgrade1Cost)
          {
              productionUpgrade1Level++;
              coins -= productionUpgrade1Cost;
              productionUpgrade1Cost *= 1.07;
          
              
          }
    
      }
    
      public void BuyProductionUpgrade2()
      {
          if (coins >= productionUpgrade2Cost)
          {
              productionUpgrade2Level++;
              coins -= productionUpgrade2Cost;
              productionUpgrade2Cost *= 1.09;
            
          }
    
      }
    

    }

May you check if you successfully trigger BuyProductionUpgrade2()? And use Console.Log to check if value “productionUpgrade2Level” or “productionUpgrade2Power” behaves unexpected?

out of topic, i think it’s easy to use float instead of double, do that you can use PlayerPrefs.GetFloat. to define a float number, just add “f” as suffix (1f, 2.0f, etc)