My player lives section of my code is not functioning properly

I’m working on a game for my portfolio class and I have poured over the forums and answers to get assistance with my issue. I’m now posting my question to get some answers from the community.

I have a destroy by contact script for my hero character, but I added a couple lines that would give the player a certain amount of lives and when he dies, the level would restart and when he reaches zero lives, then the game over screen would come up. The problem is that the player restarts over and over again but the game over screen never comes up when the player should be game over.

I got some of the script pieces from the forum, I’ve tried using Random.Range but then I get an error saying that I can’t turn an integer into a boolean.

using UnityEngine;
using System.Collections;

public class DbyContact : MonoBehaviour {

public GameObject explosion;
public GameObject playerExplosion;
public int scoreValue;
public int lives;
private GameController gameController;

void Start ()
{
	GameObject gameControllerObject = GameObject.FindWithTag ("GameController");
	if (gameControllerObject != null)
	{
		gameController = gameControllerObject.GetComponent <GameController>();
	}
	if (gameController == null) 
	{
		Debug.Log ("cannot find 'GameController' script");
	}

	}
	
	void OnTriggerEnter(Collider other) {
		if (other.tag == "Boundary")
		{
			return;
		}
		if (other.tag == "pBullet") 
		{
			return;
		}
		if (other.tag == "eBullet")
		{
			Instantiate(explosion, transform.position, transform.rotation);
		lives -=1;
		if (lives<=3)
		{
		Application.LoadLevel (Application.loadedLevel);
		}
		if (lives<=0)
		{
			Application.LoadLevel ("GameOver");
	}		
		if (other.tag == "Enemy") 
		{
			Instantiate (explosion, other.transform.position, other.transform.rotation);
		lives -=1;
			if (lives<=3)
			{
				Application.LoadLevel (Application.loadedLevel);
		if (lives<=0)
		{
				Application.LoadLevel ("GameOver");
		//Loser.Restart ();
	}
			}
	//if (lives <= 0) 
	//{
	//	Application.LoadLevel ("GameOver");
	//}
	gameController.AddScore (scoreValue);
	Destroy(other.gameObject);
	Destroy(gameObject);
	}
}
}
}

I can think of 3 basic ways to solve this, each with their own issues.

Option Number One is to call DontDestroyOnLoad on your player, and then set him at the start of the level once ith as been loaded. The problem here is that if you start with a player existing in your level, there will be 2 players when the level is reloaded, so you will have to think of something to resolve that.

The second option is to not reload the entire level but instead ‘reset’ it. You’ll have to keep a reference to what all starting values and stuff are, though.

The final (probably simplest) option is to store your player’s number of lives in either playerprefs or a static class, and load that value into your player’s prefab in its Start() method. Here you mostly just have to be careful when and how you set it to it’s initial (maximum) value.