GUI.Button carrying out two functions?

So im trying to make an attribute system. When push the “Increase Health” button I want it to increase health +1 and decrease points -1. Whenever I type this it results in the points variable constantly decreasing by -1 before even pressing the button. Here is my script:

var health = 10;
var speed = 10;
var attack = 10;
var increase = 1;
var decrease = 1;

function Update(){
    if(points < 0)
        points = 0;
    if(points > 10)
        points = 10;
}

function OnGUI(){
    GUI.Box(Rect(560,0,150,25),"You have "+points+" points");
    if(GUI.Button(Rect(560,50,150,25),"Increase Health"))
        health = health+increase;
    points = points-decrease;
 
    GUI.Box(Rect(560,75,150,25),"You have "+health+" health");
 
    if(GUI.Button(Rect(560,100,150,25),"Decrease Health"))
        health = health-decrease;
    points = points+increase;
}

I just fixed your code highlighting and in turn fixed the indention of most lines. As you see an if statement always only affects the statement that directly follows the if statement. If you want to have multiple statements depend on the if statement condition, you have to group them in a “code block” with curly brackets:

if(GUI.Button(Rect(560,50,150,25),"Increase Health"))
{
    health = health+increase;
    points = points-decrease;
}

Now the if statement affects the whole code block. Also just in case you didn’t know the += and -= operators:

health += increase; // same as health = health + increase;
points -= decrease; // same as points = points - decrease;