Is it possible to access variables from another script using GetComponent?

So, I want to make a system where i want the values on my main script to change based on the values i get from another script. Something like this:

Script X:
Value : int;
OtherScript : ScriptY;

function awake ()
{
Value = null;
}

function start ()
{
OtherScript = gameObject.GetComponent(ScriptY)
}

function Update ()
{
if (OtherScript !=null)
{
Value = OtherScript.Number;
}
}

Script Y
var Number : int = 5;

Would something like this work?

Yes ! The only thing is you need to have to variable Number declared as public into the ScriptY.

Overview: Accessing Other Game Objects

Yes, you can do something like this

Script 1:

var Health = 100;

function Update() {
    //If the script is attached to another gameobject.
    Health = GameObject.Find("GameObjectName").GetComponent(ScriptName).Health;
    //or
    Health = GetComponent(ScriptName).Health;
}

Script 2:

public var Health = 49;