Making a pop up box

I want to make a gui text that appears when you press the G button and disappears when you press the G button again . Here is the code to make the box appear, but I can't figure out the disappearing part I would appreciate the help

if(Input.GetKeyDown(KeyCode.G))
{
    showText = true;
}

You can just toggle the value when the button is pressed.

if (Input.GetKeyDown(KeyCode.G)) 
{ 
    showText = !showText; 
}


Comment code repy: Trust me, it works...

using UnityEngine;

public class GUIToggle : MonoBehaviour
{
    bool showText = false;
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.G))
            showText = !showText;
    }

    void OnGUI()
    {
        if (showText)
            GUILayout.Label("Text");
    }
}

And for sake of completeness, the same in JS:

var showText : boolean;
function Update () 
{
    if (Input.GetKeyDown(KeyCode.G))
        showText = !showText;
}

function OnGUI()
{
    if (showText)
        GUILayout.Label("Text");
}

What you want to do is use the script that you have above, but insert this under the first if statement:

if(showText == true)
{
 showText = false;
} else {
 shotText = true;
}