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;
}