[SOLVED] Same script (virtually) on two gameObjects. One saves to playerprefs, one doesn't

Ugh. Sorry I’m asking this. I have two gameobjects, boss characters. Each has (nearly) the same script attached, a health script. The one works perfectly, and saves the result of the battle to playerprefs, so that after you’ve defeated him, he’s gone for good.

But the other one…

The results of the battle never save. He just reappears every time the game is started, and I don’t get it. Clearly, I’ve done something wrong, can’t see something, have bad syntax somewhere, I don’t know. Am hoping fresh eyes might see what I’m missing, because I’m banging my head against the keyboard after spending hours on this. The two scripts are below, starting with the working one. God bless, and thanks. Sorry to ask such a stupid question.

Working Script

var Name = "Guardian";
var Exp = 150;
static var GuardianHealth : int = 75;
var GuardianKilled = 0;
 
function Start(){
 if(PlayerPrefs.GetInt("GuardianDead", 0) == 1){
  //object.active = true;
  //object.enabled = true;
TowerGateOpen.GateOpen = true;
Destroy(gameObject);
}
}

     

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


 
if(GuardianHealth <= 0 )
if(GuardianKilled == 0 )
{
GuardianHealth = 0;
GuardianKilled = 1;
audio.Play();
Playerhealth.curXp += Exp;
Playermoney.curMoney += 350;
TowerGateOpen.GateOpen = true;
PlayerPrefs.SetInt("GuardianDead", 1);
Debug.Log( Name + " is killed");
Destroy(gameObject);
}
}
}

Script that won’t save to playerprefs:

var Name = "Medamomo";
var Exp = 450;
static var MedamomoHealth : int = 5;
var MedamomoKilled = 0;

 
function Start(){
if(PlayerPrefs.GetInt("MedadmomoKilled", 0) == 1){
  //object.active = true;
  //object.enabled = true;
MedamomoGateOpen.GateOpen = true;
Destroy(gameObject);
}
}

     

    function OnTriggerEnter (other : Collider){
    if (other.gameObject.name == "sword") {
    MedamomoHealth = -7;
	}
    else 
	{
	if (other.gameObject.name == "club")
	{
		MedamomoHealth = -1;
	
}


 
if(MedamomoHealth <= 0 )
if(MedamomoKilled == 0 )
{
MedamomoHealth = 0;
MedamomoKilled = 1;
//audio.Play();
Playerhealth.curXp += Exp;
Playermoney.curMoney += 1550;
PlayerPrefs.SetInt("MedamomoKilled", 1);
Debug.Log( Name + " is killed");
MedamomoGateOpen.GateOpen = true;
Destroy(gameObject);
}
}
}

Between lines 5 & 10, you seem to have misspelled “MedamomoKilled” as “MedadmomoKilled”, since player prefs don’t throw errors with unset values that might be the issue.

Just glancing, GuardianHealth is a static, which is reset to 0(?). This means when the 1st guy is killed, the 2nd guy has 0 health. Static is really special purpose. A “normal” variable would give them each their own health. Then sword and club hits have GuardianHealth = -10;, meaning they insta-kill the guy. You probably meant to use -= to subtract 10 health.

Then the death check (the two ifs) specifically says to ignore death if you’re already killed a guy.