how to access other object's script

i have 2 scripts named A and B.

i put A in Object OA and B in Object OB.

now i want to change A’s varibel “a”(int public) in script B.

how can i get a.

I don’t know all the in’s and out’s of puplic variables. But i use static talking to other scripts and controling external vars. After making the var static it will not be seen in the inspector, so with a simple debug or print to the console you can check to see if its working(if u cant see the result on screen)

Just use something like this

if(otherScriptName.staticVarsName==10){
otherScriptName.staticVarsName=0;
Debug.Log("I rule this var Now);
}

Ofc this example may not be what your doing, But will give u the general idea. :smile:

Maybe you find this interesting: It’s a script for a button which triggers a script ( to move the door ) on another Object ( the door )

var door : Transform;

function OnTriggerEnter () {
	if (door.GetComponent("move from to lerp") != null)			
	door.GetComponent("move from to lerp").OpenDoor();	
   }

It’s this part
door.GetComponent(“move from to lerp”).OpenDoor();

on the variable door the script “move from to lerp” is called and within the funktion OpenDoor is executed.
The door has been manualy linked to the button with the variable.