i need help Shop game AmountMoney can't Subtraction But it increases the number

///////Character///   recive Value formcaracter//
PlayerPrefs.SetInt("Money" +mapIndex,MoneyAmount + PlayerPrefs.GetInt("Money" +mapIndex) );

/////UI manager//////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System;

public class UIManager_2 : MonoBehaviour
{
    public static UIManager_2 instance;
    public GameObject MapSelectionPanel;
    [Header("Our STAR UI")]
    public int Stars;
    // public int Moneys;
    public Text starText;
    //public Text moneyText;
    public int Moneys2;
    public Text moneyText2;


    public void Awake()
    {
        instance = this;
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            if (instance != this)
            {
                Destroy(gameObject);
            }
        }
        //DontDestroyOnLoad(gameObject);*/
    }
    public void Start()
    {
        //PlayerPrefs.DeleteAll();
    }
    public void Update()
    {
        UpdateStarUI();
        UpdateNewMoney();
    }
    public void UpdateStarUI()
    {
        Stars = PlayerPrefs.GetInt("Star" + 1) + PlayerPrefs.GetInt("Star" + 2) + PlayerPrefs.GetInt("Star" + 3) + PlayerPrefs.GetInt("Star" + 4)
            + PlayerPrefs.GetInt("Star" + 5) + PlayerPrefs.GetInt("Star" + 6) + PlayerPrefs.GetInt("Star" + 7) + PlayerPrefs.GetInt("Star" + 8); /*PlayerPrefs.GetInt("Map" + 1) + PlayerPrefs.GetInt("Map" + 2) + PlayerPrefs.GetInt("Map" + 3) + PlayerPrefs.GetInt("Map" + 4) + PlayerPrefs.GetInt("Map" + 5) + PlayerPrefs.GetInt("Map" + 6) + PlayerPrefs.GetInt("Map" + 7) + PlayerPrefs.GetInt("Map" + 8);*/
        starText.text = Stars.ToString() + ("/24");
    }
   public void UpdateNewMoney()
    {
        Moneys2 = PlayerPrefs.GetInt("Money" + 1 )+ PlayerPrefs.GetInt("Money" + 2) + PlayerPrefs.GetInt("Money" + 3) + PlayerPrefs.GetInt("Money" + 4)
                 + PlayerPrefs.GetInt("Money" + 5) + PlayerPrefs.GetInt("Money" + 6) + PlayerPrefs.GetInt("Money" + 7) + PlayerPrefs.GetInt("Money" + 8);
        moneyText2.text = Moneys2.ToString() + (" B");
    }
}
/////////////////////////////shop Game////
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System;

public class ShopManager : MonoBehaviour
{
    public int Money;
    public Text moneyText;
    public int item1;
    //public int item2;
    public GameObject shop;
    public int Moneys3;
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        UpdateMoney();
       

    }
    public void UpdateMoney()
    {

        Money = UIManager_2.instance.Moneys2;
        moneyText.text = "Money :" + Money;
    }
    public void BuyItem()
    {
        if (Money >= item1)
        {
            Moneys3 = Money - item1;
            PlayerPrefs.SetInt("Money3", Moneys3);
        }
        else
        {
            Debug.Log("NoMoney");
        }
    }
    public void OpenShop()
    {
        shop.gameObject.SetActive(true);
    }
    public void ExitShop()
    {
        shop.gameObject.SetActive(false);
    }
}

bigfelinedachshund

To help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

Doing this should help you answer these types of questions:

  • is this code even running? which parts are running? how often does it run?
  • what are the values of the variables involved? Are they initialized?

Knowing this information will help you reason about the behavior you are seeing.

Plase Help me i try it 3days Not finished my shop tepidblissfulblackwidowspider

I assure you the person best positioned to solve this is you, by the steps outlined above.

If you are unwilling to do the engineering, I’m sorry, I cannot do it for you.