Accessing a variable within a function.... GetComponent()

I know how to get a variable that is public but how would I get one inside a function (Update function)?

Is it somewhat like this?

 var script = GetComponent(ScriptName).Update();
 script.variable = blah;

Variables declared inside a function are local to that function and can't be accessed outside by any means. Any variables you need to access from other scripts must be public.

You need to declare the variable as public before the Update Function. Then you can use this same variable in your Update Function and access it directly via an outside script as you've demonstrated.

Just about any script has this implemented, for example:

var guiCenter : Vector2;                            

function Update()
{
guiCenter.x = 5;
}

In JS, public is the default attribute of any variable you declare outside of a function.