- Home /
Current health may never exceed maximum health
Hi everybody
I've made a script which displays 2 bars, the current and the maximum health. But I want to make it impossible for the current health to exceed the maximum health. I tried to use this script
var maxhealth = 100;
var curhealth = 100;
function Update () {
if (curhealth < maxhealth) {
"maxhealth" == "curhealth";
}
}
But when I assign the value of 60 to the current health and 50 to the maximum health, those values don't change into 50 current health and 50 maximum health. Does anyone know what mistake I've made in my script?
Comment
Answer by Lo0NuhtiK · Dec 28, 2011 at 04:00 AM
if(curHealth > maxHealth){ //if cur is over max
curHealth = maxHealth ; //reset cur to max -- no quotes around "variables" , also no double "=="
}
Answer by Romano185 · Dec 28, 2011 at 03:07 PM
Thanks, this solves my problem. I'm not very good at scripting, but this'll really help me to learn it.