How to create a button when clicking a game object?

I currently have the following script, and I want it to be so that when I click on a game object, it should show a button in my GUI. But, currently the button doesn’t show up when clicking on the gameObject. While the function itself works when I add a Debug.Log, it will return the right value.

function OnGUI () {
	if (Input.GetMouseButton(0)) {
		ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		var hit: RaycastHit;
		if (Physics.Raycast(ray, hit) && Input.GetMouseButtonDown(0) && hit.transform.tag == "component") {
			if(GUI.Button (Rect (Screen.width - 120,130,100,25), "Delete")) {
				//DeleteObject();
			}
		}
	}
}

You could just do this and add the script to every single game object with the tag: “Component”:

private var guiEnabled : bool = false;

function OnMouseUp ()
{
    guiEnabled = true;
}

function OnGUI()
{
    if (guiEnabled)
    {
        if(GUI.Button(Rect(Screen.width - 120,130,100,25), "Delete"))
        {
            // Destroy!
        }
    }
}