Accessing variable from another script.

Hello, I am trying to make a boss states… In boss animator, I created Idle to walk animation connection. On my idle animation(in animator), I attached Behaviour script in which I want to get variable from a boss health script(animator and scripts are on the same object). So that when boss health is for example <= 50 he starts walking aka animator.SetBool(“isFollowing”, true); which will make him transfer from idle to follow behaviour which is coded to follow me…
How can I reference his health value in his behaviour script if they are on his- same- object.

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

public class IdleBehaviour : StateMachineBehaviour
{
    //reference health value from EnemyHealth script

    void Start()
    {
        //HHealth = GameObject.Find("Hiram").GetComponent<EnemyHealth>();
 
    }
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
       
    }

    
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // if his health is lower than 50, isFollowing bool is true
    }

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
      
    }
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;

public class EnemyHealth : MonoBehaviour
{
public int currentHealth;
public float damage = 10;
public void TakeDamage(int damage)
    {
        currentHealth -= damage;
        //animacija primljenog udarca

        if(currentHealth <= 0)
        {
            Die();
           
        }
    }
}

If they are on the same GameObject, GetComponent().currentHealth will return the currentHealth value on the EnemyHealth component on that object…however, I would suggest maybe considering setting up an event so that the Behavior script can subscribe to the event and the event gets called passing in the health value or just when the health reaches certain points.

Could You make it visible like in my code? I am not really getting it… :confused: Thanks