Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

How do I chang values? [closed]

Asked by
lucas4114 607 Moderation Voter
9 years ago

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?

0
Should be : health=health-1 --try that woodengop 1134 — 9y
0
Look at all the answers please. Not just the top one, so you can get all the information you need! EzraNehemiah_TF2 3552 — 9y

Closed as Not Constructive by AmericanStripes

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
1
Answered by 9 years ago

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
0
How did you become an administrator. Is it because you were one of the first like 50 people to join? EzraNehemiah_TF2 3552 — 9y
0
No @Lord, to be an Admin you have to be active, And chosen by the Owner. woodengop 1134 — 9y
0
Active? Dang it. I haven't been on for a couple days... EzraNehemiah_TF2 3552 — 9y
0
Changing the `health` variable won't change the property of the Humanoid. It *just* changes the `health` variable. BlueTaslem 18071 — 9y
View all comments (2 more)
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... EzraNehemiah_TF2 3552 — 9y
0
Better? FearMeIAmLag 1161 — 9y
Ad
Log in to vote
1
Answered by 9 years ago
  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!