Access Variable From FirstPersonController Script

I want to access the FirstPersonController script on my Player GameObject to access the m_IsWalking boolean to find out if the player is walking and play an animation if they are and Idle animation if they aren’t

I’ve Tried:
FirstPersonController script = GameObject.FindGameObjectWithTag(“Player”).GetComponent(“FirstPersonController”);

Bool isWalking = script.m_IsWalking;

AND I’VE TRIED

FirstPersonController script = GameObject.FindGameObjectWithTag("Player").GetComponent<FirsPersonController>;

Bool isWalking = script.m_IsWalking;

Could someone tell me how to access the m_IsWalking boolean from another script?

I do not have the source code of FirstPersonController, but if the variable is private or protected, you cannot access it directly. You need a getter, if it does not exists you can create it

public bool IsWalking(){
    return m_IsWalking;
}

I recommend to look directly at the animation currently running (game object → animation component → animation controller ) Unity - Scripting API: Animator , you need to see in which state is it now (or in a transition).

Another way is to see if it has velocity Unity - Scripting API: Animator.velocity