Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I chang values?

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?

2 comments

0

Should be : health=health-1 --try that

0

Look at all the answers please. Not just the top one, so you can get all the information you need!

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

0

How did you become an administrator. Is it because you were one of the first like 50 people to join?

0

No @Lord, to be an Admin you have to be active, And chosen by the Owner.

0

Active? Dang it. I haven't been on for a couple days...

0

Changing the health variable won't change the property of the Humanoid. It just changes the health variable.

0

Do: health = game.Players.FearMeIAmLag.Character.Humanoid while wait(2) do health.Health = health.Health-1 end maybe the script will actually work then...

0

Better?

  1. Make new variables local
  2. No need to wait 2.03 seconds. Just do while wait(2) do instead of while wait() do wait(2)
  3. 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.