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

How to loop this poison script? [Solved]

Asked by 10 years ago

So I want to shorten this by like tonnes... But I have no idea how to make it loop, so I just repeat it... Which is time consuming. And it also makes it really long... Does anyone have an idea how to loop it?

game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health-0.1 
wait(1) 

So I want to make that repeat... Instead of having it over and over... Thanks.

3 answers

Log in to vote
0
Answered by 10 years ago

Hmm, try this;

repeat wait(1) game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health-0.1 until --This will repeat infinitly if you set it to 'nil', or add nil to it, but you can also set it to stop at a certain point if you want it to

Hope this helped!

0
Yeah thanks. And umm just asking, would that make sure the person doesn't regenerate health? DerpyShadowz 34 — 10y
0
Well, if you add a 'nil' after the 'until' statement, then it'll keep damaging the player until death, but if you set it to like 'until game.Workspace.Players.Humanoid.Health == 50', then it'll keep on going until health reaches 50. TheeDeathCaster 2368 — 10y
0
Aw okay thanks. DerpyShadowz 34 — 10y
Ad
Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

If you have a given amount you want to poison, I'd use a for loop. It would look something like this.

for i = 1, 10 do -- Execute the following code 10 times
    Humanoid:TakeDamage(3) -- Subtract 3 from the Humanoid's health
end -- close for loop scope
Log in to vote
-1
Answered by
LAC44 20
10 years ago

Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.

while wait(1) do game.Workspace.Player.Humanoid.Health = game.Workspace.Player.Humanoid.Health-0.1 end

Answer this question