Check out example codes for "get variable from other scriptin unity c#". It will help you in understanding the concepts better.

Code Example 1

//-------------------------------PUT IN ScriptA-----------
public ScriptB = scriptB;

void Start()
{
  scriptB.myFloat = 3.542f;
}
//---------------------------------------------
//---------------------------PUT IN ScriptB---------
//make sure public so it can be accessed from other scripts.
public float myFloat;
//script a will change myFloat to 3.542 from null;
//note this is for Unity and C#

Code Example 2

//Make Health public
public class PlayerScript: MonoBehaviour {
  public float Health = 100.0f;
}

//Access it.

public class Accessor : MonoBehaviour {
    void Start()
    {
        GameObject thePlayer = GameObject.Find("ThePlayer");
        PlayerScript playerScript = thePlayer.GetComponent<PlayerScript>();
        playerScript.Health -= 10.0f;
    }
}

Code Example 3

public class Script1 : MonoBehavior
{
public static int Script1Int;
}
//Another script:

public class Script2 : MonoBehavior
{
public static int Script2Int;

	void Start()
	{
    	Script2Int = Script1.Script1Int;
    }
}

Learn ReactJs, React Native from akashmittal.com