problems accessing variables and functions in another script

I have two scripts main and joints.

I want to access functions and variables in joints from main.

I have a gameObject named MainObject which both scripts are attached to.

This is not working so far.


var myarray=new Array();  


var myjoints:joints;  
Debug.Log(myjoints);//returns MainObject (joints);  
Debug.Log(myjoints.myarray[0]);//returns out of index.

It seems like it finds the joints script but not any variables attached to the script.
Can anyone explain why this is not working?



This has been answered before, but here goes again…

(BTW, please use code tags to define your code, it’s the button with the 1’s and 0’s on it)

Your MAIN should get the connection to JOINTS this way:

var myjoints;

GameObject (with capital G is different than gameObject.
Lowercase g means the gameobject this script is attached to.
Only use capital G to refer to the GameObject type.
Also, there was no need to do the Find(), just use GetComponent.
You only need to do the Find when you are looking outside the current GameObject…