#Can't make integer value go up automatically

1 messages · Page 1 of 1 (latest)

errant gust
#

Basically I'm writing a script which makes the players stamina go up by +10 per second while it is less than 100 but for some reason it just doesn't work. I'm probably missing something really obvious but I just can't figure it out.


while StaminaValue < 100 do
    StaminaValue += 1
    wait(0.1)
end```

(StaminaValue is an int value which is a child of the script)
ancient badgeBOT
#

studio** You are now Level 1! **studio

undone hill
#

StaminaValue contains StaminaValue.Value at the time it stores it, not a link to the object.

Instead, either save script.StaminaValue to a variable and do StaminaValue.Value when you need to read / set it, or use script.StaminaValue.Value directly