So I have a NumberValue that is called Health and I want the max health to be 1000 and the min 0, if at any point it is under 1000 I want it to regenerate back to 1000 with a random interval of 1 to 50 but after 1000 it continues forever? Help! Here is what I had:
script.Parent.Value = 1000
while script.Parent.Value <= 1000 do
repeat
script.Parent.Value = script.Parent.Value + math.random(1,50)
wait(math.random(1,5))
until
script.Parent.Value == 1000
end

2 comments
I tried this but It still didn't work : script.Parent.Value = 1000 while script.Parent.Value <= 1000 do repeat script.Parent.Value = script.Parent.Value + 10 wait(math.random(1,2)) until script.Parent.Value == 1000 end
I made an update on it.