++ Changes variable to 121?

I know exactly why this is happening. My function is OnGUI. I have my simple script saying that when a button is pressed it adds a variable +1. It adds 121 or some times 50 - it’s random. I know why it happens - because it measures how long the button is pressed for. I’m guessing that the “if (GUI.Button…” statement is set for when the mouse it pressed, not let go. Does anyone know how to make it so when you click the button, it adds 1 only??? Thanks!!!

You need curly braces around an if statement that is more than one line.

if (GUI.Button (Rect(10,10,50,50), "Click?"))
{
   print(Respect);
   Respect +=1;
}

The first example works because without curly braces, the first line after the if statement is the body of the statement

That is

if (GUI.Button (Rect(10,10,50,50), "Click?"))
   Respect +=1; //the if statement applies to this line
   print(Respect); //but not this line

but here

if (GUI.Button (Rect(10,10,50,50), "Click?"))
{  //with curly braces
   Respect +=1; //the if statement applies to this line
   print(Respect); //the if statement applies to this line too
}