How to change a variable in a script on one object from a script on another object?

I need to make a script on an object change a variable in a script on a camera. I’ve read countless answers via google and I think I’m close to getting it to work but I can’t quite get it to happen. Can anyone tell me what I’m doing wrong? Here’s what I’ve got (javascript):

The variable in a script on my main camera:

public static var variableInTheCameraScript = false;

The script on the object:

var findCamera : GameObject;
var getScript : MonoBehaviour;

function Start(){
    
	findCamera = GameObject.Find("Main Camera");
	getScript = findCamera.GetComponent(ScriptOnTheCamera);

}

function OnGUI(){
    
    if (Input.GetMouseButtonDown(0)){
    	    
		getScript.variableInTheCameraScript = true;
    
    }
    
}

This gives me the error “variableInTheCameraScript is not a member of UnityEngine.MonoBehaviour.”

I’ve also tried changing getScript to a boolean and using:

findCamera.GetComponent.getScript.variableInTheCameraScript = true;

Which gives the error “getScript is not a member of function(System.Type): UnityEngineComponent”

The variable variableInTheCameraScript is static, you can retrieve it from the class itself.

ScriptOnTheCamera.variableInTheCameraScript

If the variable is not static, you have to use a GetComponent to get the script on the game object and retrieve the variable from there (as shown in your 2nd code example).

Your static variableInTheCameraScript cant be accessed in an Instance of its Parenting class.

Just do: "YourClassThe-variableInTheCameraScript-IsIn".variableInTheCameraScript = true / false;

Awesome thank you, that did the trick. Looks like I was over-complicating it.