Unity 2018.1.5 How can I reach a variable in a Parent game object from a child of that object

My goal is to create a system where a player can shoot different body parts of an enemy and deal different amounts of damage depending on which body part they hit. Enemies are instantiated from a prefab. The enemy’s health is stored as an int value in the parent game object. Here is the enemy code I have:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.SceneManagement;

public class Enemy : MonoBehaviour
{
    NavMeshAgent agent;
    Transform objectToChase;
    public GameObject ZombieRenderObject;
    Animator ZombieAnimator;
   
    //reference to the players gun
    GunData gundata = new GunData();

   // [SerializeField] Transform spawnPoints;

    int spawnPoint;
    public int zombieHealth = 100;
    public bool tracking = true;


    //references (player, scoreboard)
    private GameObject player;

    //functions for zombie health
    public int ZombieHealth
    {
        get
        {
            return zombieHealth;
        }

        set
        {
            zombieHealth = value;
        }
    }

   
    void Start ()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        ZombieAnimator = ZombieRenderObject.GetComponent<Animator>();
        objectToChase = player.transform;

        agent = GetComponent<NavMeshAgent>();

        //dev tool to make them not chase you while testing
        if(tracking == true)
        agent.SetDestination(objectToChase.position);
       
    }
   
    // Update is called once per frame
    void Update () {

        //dev tool to make them not chase you while testing
        if (tracking == true)
        { agent.SetDestination(objectToChase.position); }

        ZombieAnimator.SetFloat("zombieSpeed", agent.velocity.magnitude / agent.speed);

        CheckDeath();
    }

    //finds the player and sets a destination towards them using the navmesh
    void SetDestination()
    {
        agent.SetDestination(objectToChase.position);
    }

    //method to damage zombie
    void OnCollisionEnter(Collision collision)
    {
        //Check for a match with the specified name on any GameObject that collides with your GameObject
        if (collision.gameObject.name == "Bullet")
        {
            Debug.Log("I got shot");
            //zombieHealth -= 50;
            Debug.Log("Damage Dealt = ");

            ScoreTotal.scoreTotal += 10;
            HighScore.highScore += 10;
        }
        else
            return;
    }

    void CheckDeath()
    {
        if(this.zombieHealth <= 0)
        {
            Destroy(gameObject);
        }
    }
}

Ideally I could put a collider on each limb with each limb having a unique script. The limbs are child game objects of the Enemy game object. What I don’t know how to is manipulate the zombieHealth variable in the Enemy script from the unique limb scripts. Here is what I have so far for the limb scripts:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeadShot : MonoBehaviour
{

    public int zombieHealth;

    // Use this for initialization
    void Start()
    {

    }
    // Update is called once per frame
    void Update ()
    {
       
    }

    void OnCollisionEnter(Collision collision)
    {
        //Check for a match with the specified name on any GameObject that collides with your GameObject
        if (collision.gameObject.name == "Bullet")
        {
            Debug.Log("I got shot in the head");
            zombieHealth -= 50;
            Debug.Log("Damage Dealt = ");

            ScoreTotal.scoreTotal += 10;
            HighScore.highScore += 10;
        }
        else
            return;
    }

}

I hope this is question makes sense. Any advice would be appreciated.

There’s a few possible options, but GetComponentInParent seems like the most obvious one.

i can think of a few ways to do something like this.

If you only want one script, then put a script on the enemy root game object that has a list of all transforms that are damageable, as well as the damage multiplier for that limb.

when an object is hit, it immediately checks its root object for the DamageScript, and then checks to see if the transform hit is contained in the list. If it is, then it applies the damage based on the multiplier.

Alternatively, there really isn’t anything wrong with having a DamageLink script placed on each transform that needs one. The health script would still but on the root, but you could link the scripts via the inspector or GetComponentInParent to aquire the link to the health script.

This is the direction I needed. I got the code to work correctly with the following script:

public class HeadShot : MonoBehaviour
{
    public Enemy thisZombie;

    public int damageToDeal = 50;

    public int scorePoints = 50;

    // Use this for initialization
    void Start ()
    {
        thisZombie = GetComponentInParent<Enemy>();
    }
   
    // Update is called once per frame
    void Update ()
    {
       
    }

    void OnTriggerEnter(Collider other)
    {
        //Check for a match with the specified name on any GameObject that collides with your GameObject
        Debug.Log("The head touched something");
        if (other.gameObject.tag == "Bullet")
        {
            Debug.Log("I got shot in the head");
            thisZombie.zombieHealth -= damageToDeal;
            Debug.Log("Damage Dealt = " + damageToDeal);

            ScoreTotal.scoreTotal += scorePoints;
            HighScore.highScore += scorePoints;
        }
        else
           return;
    }

}