While loops doing what they need to multiple times?
In my game, I am working on adding a Poison status effect, I have two while loops doing two different things; one is counting down the venom value when it is more than 0, and the other is removing the player's health as long as the value is above 0. The problem is, the loops start doing their function multiple times. For example, the while loop that is supposed to be counting the venom value down while it is above 0 will work fine for the first loop, but then the loop starts stalking on top of itself, and won't even stop when it is at 0. Instead, it counts down like this: 10, 9, 7, 3, -5, and then stops at -5. I have no idea why this is happening, help would be appreciated.
01 | char.charactervalues.Venom.Changed:Connect( function () |
02 | if char.charactervalues.Venom.Value > 0 then |
03 | char.Torso.Poison.Enabled = true |
04 | while char.charactervalues.Venom.Value ~ = 0 do |
05 | char.Humanoid.Health - = 3 |
09 | char.Torso.Poison.Enabled = false |
13 | char.charactervalues.Venom.Changed:Connect( function () |
14 | if char.charactervalues.Venom.Value > 0 then |
15 | while char.charactervalues.Venom.Value ~ = 0 do |
17 | char.charactervalues.Venom.Value - = 1 |