int OnTriggerEnter(Collider other) { if (other.gameObject.CompareTag("Bullet")) { Destroy(other.gameObject); durability -= 1; if (durability <= 0) { Destroy(gameObject); explosion.Play(true); scoreScript.IncreaseScore(points); } } else if (other.gameObject.CompareTag("Wall")) { // Get a reference to a health script attached to the collider we hit WallControl health = other.gameObject.GetComponent <WallControl>(); // If there was a health script attached if (health != null) { // Call the damage function of that script, passing in our enemy damage variable health.Damage(damage); } Destroy(gameObject); } return(durability); }