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

How to loop this poison script? [Solved]

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

✓ Accepted answer

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!

3 comments

0

Yeah thanks. And umm just asking, would that make sure the person doesn't regenerate health?

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.

0

Aw okay thanks.

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.