invoking a function in other scripts?

Hello. When something in a script happens, I want to invoke a function that is in aother script attached to several objects.

Every instance of the the object “Test” has “ScriptA” attached to it, which has the function “Go”. But, when I press the button, none of the instances of the function Go, are invoked…why?

function Update () {
    if (Input.GetKeyDown ("w")){


GameObject.Find will only find one other object. If you want to call the function on multiple objects, you will have to do something slightly different-

First, give all the relevant objects the tag 'Test'.

for(var obj : GameObject in GameObject.FindGameObjectsWithTag("Test"))

The GameObject that will affect all your ScriptAs must have an array or a list referencing them. Several way to do this, here is the one I have in minde:

In your ScriptA's Start/awake function, look for the main script (use a tag, it's faster), then call something like

mainScript = GameObject.FindGameObjectsWithTag("MainScript");
mainScript.AddScriptA( this );

In your main script create the public function and the arrayList

public function AddScriptA( ScriptA a ){ arrayList.Add( a ); }

finally, still in the mainScript

function SomeEvent(){
   foreach( ScriptA A in arrayList ) A.Go();

That way, the Find function is called only once. per ScriptA, instead of once per scirptA per event.