I have the fallowing script I am using to respawn my ship when it gets destroyed but the problem is with the line that is subtracting from the lives its not doing it.
using UnityEngine;
using System.Collections;
public class Spawn : MonoBehaviour
{
public Transform ship;
public bool death1 = false;
public bool death2 = false;
public Transform location1; // The teleport after death location
private Transform newShip;
void Start ()
{
if(death1)
{
GameObject clone = Instantiate (ship, location1.position, location1.rotation)as GameObject;
newShip = GameObject.FindWithTag("Player").transform;
GameObject varGameObject = GameObject.Find("Main Camera"); // Finds the main ship
varGameObject.GetComponent<CameraFollow>().enabled = true; // Finds the fly script and turns it off if we die
varGameObject.GetComponent<CameraFollow>().target = newShip; // Finds the fly script and turns it off if we die
varGameObject.GetComponent<ShipHealth>().lives --;
// varGameObject.GetComponent<Spawn>().enabled = false; // Finds the fly script and turns it off if we die
}
if(death2)
{
GameObject clone = Instantiate (ship, location1.position, location1.rotation)as GameObject;
newShip = GameObject.FindWithTag("Player").transform;
GameObject varGameObject = GameObject.Find("Main Camera"); // Finds the main ship
varGameObject.GetComponent<CameraFollow>().enabled = true; // Finds the fly script and turns it off if we die
varGameObject.GetComponent<CameraFollow>().target = newShip; // Finds the fly script and turns it off if we die
varGameObject.GetComponent<ShipHealth>().lives --;
// varGameObject.GetComponent<Spawn>().enabled = false; // Finds the fly script and turns it off if we die
}
}
}