Problems enabling my GUI Texture via script.

So my basic premise is that I don’t want the GUI to show up until the player clicks the start button.

Below is the very rudimentary script I’m using to make this happen.

static var gameOn : int = 0;

function OnGUI(){
	if(gameOn == 0){
		if(GUI.Button(Rect(10,70,50,30),"Click")){
			gameOn = 1;
			GameObject("GUI Console").guiTexture.enabled = true;
		}
	}
}

Problem is when I click the button, I get this error:

However there is, in fact, a gui texture attached to said object. I’ve disabled it, so it can be enabled when this button is clicked. Yet even when I try things in reverse (initially enabling the texture, and telling the button to disable it) I get the same error.

There’s another script, built into the GUI Console game object itself, that references the texture quite regularly just fine.

What am I doing wrong heere?

			GameObject("GUI Console").guiTexture.enabled = true;

Hi!
You can´t reference a gameobject like you are trying to. You need to find it some other way, like GameObject.Find(“GUI Console”).
Once you figure out how to get a reference to other gameobjects, like Find, FindWithtag, FindObjecofType etc, you will be fine.

Aha! Works absolutely perfectly now. Thank you very much. Simple mistakes are always the worst. heh