PlayerPrefs and Text not working but no errors are given.

Hi,
The following scripts are meant to display the amount of WipeOuts left in the game according to how many the player has already used, however it is not working. Unfortunately, I am getting no errors and can’t see what the problem is. Many thanks for any help I get as i am kind of a noob to Unity and this is my first game.
Many thanks,
Josh :slight_smile:

Text Display Script:

using UnityEngine;
using UnityEngine.UI;

public class NumOfWipeOutsCounter : MonoBehaviour
{
    public int WipeOuts = 0;
    public Text NumOfWipeOutsTextCounter;

    void Start ()
    {
        //PlayerPrefs.SetInt("WipeOutsMaster", WipeOuts);
        Debug.Log("TestStart");
    }

    // Update is called once per frame
    void Update ()
    {
        //PlayerPrefs.SetInt("WipeOutsBase", WipeOuts);

        //int WipeOutsInternal = PlayerPrefs.GetInt("WipeOuts");

        //NumOfWipeOutsTextCounter.text = "Wipe Outs :" + WipeOuts.ToString();

        int WipeOutsMasterInternal = PlayerPrefs.GetInt("WipeOutsMaster");

        NumOfWipeOutsTextCounter.text = "Wipe Outs :" + WipeOutsMasterInternal.ToString();

        Debug.Log("WipeOutMasterInternal :" + WipeOutsMasterInternal);

        Debug.Log("TestUpdate");
    }
}

Main Wipe Out Controller Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

public class WipeOut : MonoBehaviour
{
    //NumOfWipeOutsCounter WipeOutCounterInternal;
    //public GameObject WipeOutCounterInternal;
    public GameObject WipeOutPrefab;
    //public GameObject WipeOutCounter;
    //public GameObject numOfWipeOutsCounterInternal;
    public GameObject Balloons;
    public GameObject WipeOutCounter;
    GameObject wipeOutCounter;
    //WipeOutCounter wipeOutCounter;
    bool allowWipeOut = false;
    NumOfWipeOutsCounter numOfWipeOutsCounter;
    float destroyTimer = 0.25f;

    // Start is called before the first frame update
    void Start()
    {
        WipeOutCounter = GameObject.Find("WipeOutCounter");
        //numOfWipeOutsCounter = WipeOutCounterInternal.GetComponent<NumOfWipeOutsCounter>();
        numOfWipeOutsCounter = WipeOutCounter.GetComponent<NumOfWipeOutsCounter>();
        GameObject WipeOutPrefab = GameObject.Find("Pixel Art Character 1 Export");
        Debug.Log("WipeOutScriptStarted");
    }

    // Update is called once per frame
    void Update()
    {
        int WipeOutMasterInternal = PlayerPrefs.GetInt("WipeOutsMaster");

        int TestWipeOuts = PlayerPrefs.GetInt("WipeOutsBase");

        if (/*numOfWipeOutsCounter.WipeOuts*/WipeOutMasterInternal >= 1)
        {
            allowWipeOut = true;
            Debug.Log("WipeOutStage1");
        }

        if (allowWipeOut = true && Input.GetKeyDown("space"))
        {
            Instantiate(WipeOutPrefab);
            //numOfWipeOutsCounter.WipeOuts--;
            WipeOutMasterInternal--;
            Destroy(GameObject.Find("Balloons(Clone)"));
            Destroy(GameObject.Find("PixelArt Character 1 Export(Clone)"), destroyTimer);
            Debug.Log("WipeOutStage2");
        }
        if (/*numOfWipeOutsCounter.WipeOuts*/WipeOutMasterInternal == 0)
        {
            allowWipeOut = false;
            numOfWipeOutsCounter.WipeOuts = 0;
            Debug.Log("WipeOutStage3");
        }
    }
}

Wipe Out Purchase Script :

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

public class GoldPurchaseScript : MonoBehaviour
{
    //THIS IS THE WIPE OUT PURCHASE SCRIPT - NOT THE GOLD PURCHASE SCRIPT

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void ButtonClick ()
    {
        Debug.Log("Button Clicked");
        //int NumOfWipeOuts = PlayerPrefs.GetInt("WipeOutsBase");

        //PlayerPrefs.SetInt("WipeOuts", NumOfWipeOuts + 20);

        int BuyWipeOutsCounterInternal = PlayerPrefs.GetInt("WipeOutsMaster");

        //PlayerPrefs.SetInt("WipeOutsMaster", PlayerPrefs.GetInt("WipeOutsMaster") + 20);
        PlayerPrefs.SetInt("WipeOutsMaster", BuyWipeOutsCounterInternal + 20);
    }
}

Again thanks,
Josh :slight_smile:

Fixed this issue - all I had to do was nest the bottom two if statements in the top if statement and that fixed the problem.