[SOLVED] A Playerpref in one place is blocking all my other Playerprefs

So in fixing one issue, I’ve come across a whole new (potentially bigger) issue. I’ve been using Playerprefs to save most everything. (Player health, money, items, etc.) Everything was working fine. I came to the new problem of wanting to save enemy status. In other words, when the player killed an enemy, I wanted the enemy to stay dead. (important for boss characters between game sessions) So after several hours over Skype with a very generous fellow Unity fan we had a working script which did exactly what I needed, the enemy does not come back to life after game sessions. HOWEVER, now nothing that would previously save or load does either. It’s almost like the new script is blocking any other Playerprefs from saving / loading. Even the debug log doesn’t get called anymore. I’m stumped, and am hoping someone might be able to point me in the right direction. Thanks, and God bless. The scripts are below, starting with the Playerprefs master script, which was previously working, then the new script.


function Start() {
function autoSaveEnable() {
 for(var x = 1; x>0; x++) {
yield WaitForSeconds(5);
Debug.Log("save me");
// a function created to save a game
    function OnSave()
        PlayerPrefs.SetInt("CurXp", Playerhealth.curXp);
        PlayerPrefs.SetInt("MaxXp", Playerhealth.maxXp);
        PlayerPrefs.SetInt("MaxHealth", Playerhealth.maxHealth);
        PlayerPrefs.SetInt("CurHealth", Playerhealth.maxHealth);
        PlayerPrefs.SetInt("Level", Playerhealth.level);
        PlayerPrefs.SetInt("Money", Playermoney.curMoney);
        PlayerPrefs.SetInt("HardTack", Inventory.HardTack);
        PlayerPrefs.SetInt("HealthPotion", Inventory.HealthPotion);
    // a function created to load a game
    function OnLoad()
       Playerhealth.curXp = PlayerPrefs.GetInt("CurXp");
       Playerhealth.maxXp = PlayerPrefs.GetInt("MaxXp");
       Playerhealth.maxHealth = PlayerPrefs.GetInt("MaxHealth");
       Playerhealth.curHealth = PlayerPrefs.GetInt("CurHealth");
       Playerhealth.level = PlayerPrefs.GetInt("Level");
       Playermoney.curMoney = PlayerPrefs.GetInt("Money");
       Inventory.HardTack = PlayerPrefs.GetInt("HardTack");
       Inventory.HealthPotion = PlayerPrefs.GetInt("HealthPotion");


static var GuardianHealth : int = 5;
function Start(){
 if(PlayerPrefs.GetInt("GuardianDead", 0) == 1){
  //object.active = true;
  //object.enabled = true;


    function OnTriggerEnter (other : Collider){
    if (other.gameObject.name == "sword") {
    GuardianHealth = -10;
	if (other.gameObject.name == "club")
		GuardianHealth = -1;

if(GuardianHealth <= 0 )
GuardianHealth = 0;
PlayerPrefs.SetInt("GuardianDead", 1);

Go figure. Another script WAS blocking the other Playerprefs, but not the script I thought. I had forgotten about my entirely separate EXP script, which gets called on destroy. Unfortunately, since it did, the command never fired to save anything else to Playerprefs. Simply eliminating that script, and placing its contents into the enemy health script solved my issue.