Problem with accessing variable form other scripts.

I’m trying to make a button that makes a variable in another script true but i get this error every time. Please help. Code:

Error: NullReferenceException: Object reference not set to an instance of an object
Gui.OnGUI () (at Assets/Scripts/Gui.js:29)

    #pragma strict

var moveButtonHight : int;

var moveButtonWidth : int;

var attackButtonHight : int;

var attackButtonWidth : int;

var tempName : String = "hi";

public var CreateCharacter : boolean = false;


function Start () {

}

function Update () {

}

function OnGUI() {
    
    if (GUI.Button(Rect(Screen.width / 2, Screen.height - moveButtonHight, moveButtonWidth, moveButtonHight), "Move")){
        
        Debug.Log("Clicked move");
		var player = GameObject.Find("player").GetComponent(player).Moving;
 		//var com = player.GetComponent(player);
  		player = true;
	}

    if (GUI.Button(Rect(Screen.width / 2 - attackButtonWidth, Screen.height - moveButtonHight, attackButtonWidth, attackButtonHight), "Attack / Defend")){
        
        Debug.Log("Clicked Attack / Defend");
	
	}

	if (Input.GetKeyUp(KeyCode.C)){
			
			Debug.Log("creating character");
			
			tempName = GUI.TextArea (Rect (Screen.width /4 , Screen.height / 4, 200, 100), tempName, 16);
			
		}

}

This is not the problem throwing the error message, but the ‘var player…’ line is probably not doing what you think it is doing. You assign the new player variable the value of the Moving variable in your player script (probably False), not the variable itself. Changing player to True will not affect the Moving variable in the player script.

Regarding the Error: be sure to pay attention to case sensitivity. Player != player. Also try GameObject.FindWithTag…I think I remember having problems with GameObject.Find…