Getting a value from a gameobject

My question is how would I access another script and get variables from it i.e. Cash

I didn’d get your question. Can you explain in detail?

Please.

There are so many resources explaining how one game object’s script can access a script of another game object. At least TRY to look it up. Do a tutorial. Do a search.

Just make the variable static and use that variable in any script.
Like,

script1:-

static var abc: int;

script2:-
script1.abc=10;

Hope this will help you.

Well I have done some tutorials but im still not sure how to get values from other scripts/gameobjects here is the game im working on so I do need a way to get values from a script
sorry im using Javascripts about 90% of my scripts is in java so I need a java example

I just need an example of sending a value from one script to another without using sendmessage… think OOP getting values from another class and using it in a instance of that class
err confusing I think but someone might understand what I mean… im tired right now so I will not make much sense ahah :smile:

I retract my other statements because im a retard I already figured it out its alot like what I already do in C++ lols im sooo tired :smile:

if it’s that easy, for the sake of all that follow, provide a couple links please. Or, at the very least, the right search terms to get the right result.

A google search for “unity3d accessing a script” yielded some pages:

From script reference:
http://unity3d.com/support/documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

GetComponent in particular:

Dont’ forget the manual’s user guide:
http://unity3d.com/support/documentation/Manual/User%20Guide.html

At the top of the scripting forum page is this post with links to other common topics:
http://forum.unity3d.com/threads/19302-About-Scripting

Manual, User Guide, Scripting Reference.
It would be wise to do at least one tutorial to get yourself going in the right direction.

Also Unity Answers:

And Unity Wiki:

I like more direct answers. Here’s my quick example:

Hope this helps. This is getting stuff from a gameobject.

//variable in other script
var speed : int;

function Start()
{
  speed = 0;

}
var otherScript : OtherScript;


function Start()
{

 otherScript = FindObjectOfType(Otherscript);

}

function Update()
{
  otherScript.speed++;

}