Questions about GUI?

So I am trying to create a GUI for when the player dies (Losing health, falling off the map, etc.). Here is my code:

function OnDeath() {
// Lose Health on Death

// Reload entire level
if (health != 0) {
} else if (health == 0) {
    print("You have died.");
// Lose Score on Death
new MessageScorePoints(-dieLosePoints);


So you can see that if "health != 0", the player spawns. But if "health == 0", I would like a Box to show up that has 3 options: "Start from Last Checkpoint", "Exit to Menu", and "Exit Game". How would I do this? I tried using OnGUI but that seems it is always on the screen and can't just call/uncall it as I wish?

for do that kind of things you must use labels, buttons,textfield, and many others, to see more about it go to this page: here you can find several ways to do what you want.

function OnGUI(){
if(health == 0){
//put your labels, buttons, textfield, etc..

this will make that it only appears when you variable health is 0 if is not 0 will disappear.

Oh I see what I did wrong. In the OnDeath function, when the "health == 0", I called "Destroy(gameObject);", which I guess destroys the entire gameObject, thus having no "OnGUI" to run. So I simply commented that out and the GUI started to work. Thank you Uriel :)