Hi. Recently I made a loop that is supposed to stop when a player dies. The problem is that it doesn't. Here is my code:

while plr.Character.Humanoid.Health >0 do
		wait(20)
		print'ree'
		plr.Character.Humanoid.Health = plr.Character.Humanoid.Health + 5
		end

Note: I turned off player health regen so I could make this instead.

As you can see, I made a system where health regens every 20 seconds by 5, but this does not end when the player dies. How could I fix this?

4 comments

0

i should automatically stop and error when the characters descendants don't exist

0

it*

0

All you have to do is use the function break.

0

do you do a return end if the player's health is 0? I tried it but it isn't working