How do I do TryGetComponentInParent?

I have a game object that references a script in the parent. The script can be one of three. I would like to not make a new object and script for each type if I don’t have to. Here is the code:

public class HealthBar : MonoBehaviour
{
    float maxHP;

    void Start()
    {
        maxHP = TryGetComponentInParent<Enemy>().health;
        maxHP = TryGetComponentInParent<RangedEnemy>().health;
        maxHP = TryGetComponentInParent<SuperEnemy>().health;
    }

    void FixedUpdate()
    {
        var hp = TryGetComponentInParent<Enemy>().health;
        var hp = TryGetComponentInParent<RangedEnemy>().health;
        var hp = TryGetComponentInParent<SuperEnemy>().health;
        transform.localScale = new Vector3((hp / maxHP) / 5, 0.125f, 0f);
    }
}

What do I use in place of TryGetComponentInParent ?

Ok I got it. I had to use if statements.

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

public class HealthBar : MonoBehaviour
{
	float maxHP;
	float hp;

	void Start()
	{
		if (GetComponentInParent<Enemy>() != null)
		{
			maxHP = GetComponentInParent<Enemy>().health;
		}
		else if (GetComponentInParent<RangedEnemy>() != null)
		{
			maxHP = GetComponentInParent<RangedEnemy>().health;
		}
		else if (GetComponentInParent<SuperEnemy>() != null)
		{
			maxHP = GetComponentInParent<SuperEnemy>().health;
		}
		else
			return;
    }

	void FixedUpdate()
	{
        if (GetComponentInParent<Enemy>() != null)
        {
            hp = GetComponentInParent<Enemy>().health;
        }
        else if (GetComponentInParent<RangedEnemy>() != null)
        {
            hp = GetComponentInParent<RangedEnemy>().health;
        }
        else if (GetComponentInParent<SuperEnemy>() != null)
        {
            hp = GetComponentInParent<SuperEnemy>().health;
        }
        else
            return;
        transform.localScale = new Vector3((hp / maxHP), 0.125f, 0f);
	}
}