Hide an object via GUI Button Press

I’m trying to hide an object when I press a button on the screen. The object I’m trying to hide is called CubeInterface, and is also tagged as CubeInterface. The script is attached to CubeInterface. However, I’m getting an error with the code.

var customButton : GUIStyle;

function OnGUI () {

    if( GUI.Button( Rect( 550, 220, 100, 30 ), "here", customButton ) ){

CubeInterface.gameObject.active = false;
	
}

}

I see no reason for "CubeInterface" to mean anything to the script. If you really are putting the script on the object you want to disable, try the script below, it worked for me.


var customButton : GUIStyle;

function OnGUI () 
{
    if( GUI.Button( Rect( 550, 220, 100, 30 ), "here", customButton ) )
    {
        gameObject.SetActiveRecursively(false);
    }
}