I want to reset the health regen timer every time the player gets damaged
im not getting errors but its not working
I’ve tried looking on yt and on this website cant find a fix.
Heres the code:
– Gradually regenerates the Humanoid’s Health over time.
local REGEN_RATE = 1/2
local REGEN_RATE2 = 1/5 – Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 5 – Wait this long between each regeneration step.
local Character = script.Parent
local Humanoid = Character:WaitForChild’Humanoid’
local HealthValue = Character.HealthV
while wait() do
Humanoid:GetPropertyChangedSignal(“Health”):Connect(function()
HealthValue.Value = false
wait(5)
HealthValue.Value = true
end)
if Humanoid.Health < Humanoid.MaxHealth and Humanoid.MaxHealth == 100 and HealthValue.Value == true then
local dt = wait(REGEN_STEP)
local dh = dtREGEN_RATEHumanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
elseif Humanoid.Health < Humanoid.MaxHealth and Humanoid.MaxHealth == 250 and HealthValue.Value ~= true then
local dt = wait(REGEN_STEP)
local dh = dtREGEN_RATE2Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
end