Simple get text/number from a different script

I’m still fairly new to coding in C#, and sometimes the simplest things frustrate me for days. Having found no serviceable answers, I’m hoping someone could spare a few minutes to help me out.

At the moment I’ve got no actual code; two blank scripts. (frustration led me to delete everything and start with a blank slate; hoping to get a better grasp on the simple mechanics here)

Script A is called AbilityManagement, which is attached to the player. I need a variable in this called AbilityState.
Script B is called AbilityHUDAnimation. I want to be able to collect the AbilityState variable held in the AbilityManagement script from within the AbilityHUDAnimation script.

It’s mostly the initial learning curve that’s throwing me off. When looking at other people’s solutions, I’m not sure which sections to change, and always get errors I don’t know how to solve.

Thanks for the help!

Are you new to coding in general? To have access to the player you can do (but not limited to):

A.) Create a field that can be seen in inspector and drag the reference from the gameObject and use GetComponent() and cache the ref.
B.) Create a field of type AbilityManagement and drag the script
C.) If you are loading the player at run-time use Object.FindObjectOfType() and cache it.

Hope this helps.

Thanks for the response. I’m not new to coding (10+ years in PHP / web design), but new to C# and Unity. It’s the switch in how the language handles operations that’s causing me grief.

I’ve gotta run off for the moment, but I’ll be trying this when I get back.

I am unsure of what you mean by ‘cache it’. I have a feeling that something like this will be crucial for the project I’ve got in mind. Also, if it makes a difference, I’m making a multiplayer game, and I’ve seen comments about problems with referencing ‘player’ when there are multiple players.

I’m tackling one problem at a time, but don’t want to have to rewrite pages of code later because of something I don’t know now.

I managed to get this working. Thanks for the help Polymorphik.

For anyone else that’s interested, this guide also helped tie things together: http://unity3d.com/learn/tutorials/modules/beginner/scripting/getcomponent