GUI.Button doesn't do anything!

I’m a newbie when it comes to Unity. I am following this course on YouTube. http://www.youtube.com/watch?v=ctD5pIWUPIw. I’m making a button that respawns the player.

if (GUI.Button(Rect(Screen.width*0.5-50,180,100,40), "Respawn"{
            Debug.Log("Respawning Player!");
}

if (GUI.Button(Rect(Screen.width*0.5-50,240,100,40), "Main Menu"{
            Debug.Log("Returning to Menu!");
}

But nothing happens when I press either of the buttons! It doesn’t show the Debug Log. I tried rewriting the code, and I even copied the code directly, so what can be the problem?

Is it within a OnGUI function? ie

function OnGUI ()
{
    if (GUI.Button(Rect(Screen.width*0.5-50,180,100,40), "Respawn") ){
                Debug.Log("Respawning Player!");
    }
     
    if (GUI.Button(Rect(Screen.width*0.5-50,240,100,40), "Main Menu") ){
                Debug.Log("Returning to Menu!");
  }
}
if (GUI.Button(Rect(Screen.width*0.5-50,180,100,40), "Respawn")){

            Debug.Log("Respawning Player!");

}

 

if (GUI.Button(Rect(Screen.width*0.5-50,240,100,40), "Main Menu")){

            Debug.Log("Returning to Menu!");

}

That should fix it, Just remember every time you open something you have to close it. Open parentheses require matching close parentheses. :wink:

Was this not showing up as an error in the console?

It was just a typo. I put the parentheses like you said in my code.

can you see the button on the screen?

This. You need to get the case right too. OnGUI

I FEEL SO MUCH HERP DERP RIGHT NOW! I just had the console not show debug logs! The button was working!