I did this: health = 10 while wait() do wait(2) health - 1 end This didn't work, in the script the minus was underlined red. What would I do to subtract a value if a minus didn't work?
How do I chang values?
2 answers
In order to subract a value you will need to say health = health - 1 so that you are setting a new value on the health value. In your script, you would need the health variable to be equaled to something, such as the Player's health. I have provided a sample script with how to change a player's health from 10 to 0 over time.
game.Players.FearMeIAmLag.Character.Humanoid.Health = 10
health = 10
while wait(2) do
health = health - 1
game.Players.FearMeIAmLag.Character.Humanoid.Health = health
end
6 comments
How did you become an administrator. Is it because you were one of the first like 50 people to join?
No @Lord, to be an Admin you have to be active, And chosen by the Owner.
Active? Dang it. I haven't been on for a couple days...
Changing the health variable won't change the property of the Humanoid. It just changes the health variable.
Do: health = game.Players.FearMeIAmLag.Character.Humanoid while wait(2) do health.Health = health.Health-1 end maybe the script will actually work then...
Better?
- Make new variables local
- No need to wait 2.03 seconds. Just do
while wait(2) doinstead ofwhile wait() do wait(2) - To change a value, use the "=" or equal sign.
local health = 10 --Make newly assigned variables local
while wait(2) do --No need to wait 2.03 seconds...
health = health-1 --In order to change a value you need to use an "=" sign.
--Health is the amount of health there is minus 1.
end
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Should be : health=health-1 --try that
Look at all the answers please. Not just the top one, so you can get all the information you need!