Still have questions? Join our Discord server and get real time help.
0

# How can I stop regeneration over 80 health?

How can I make a script that does this: when a player's health goes under 80, It doesn't regen to 100, but 80 instead. If the health is above 80, then it will regen to 100. (You may be able to do to this by changing the 'Health' script inside a player's model).

Thanks

0
Edited 11 months ago

Make sure this is a Server Script, and it's named Health, and it's located inside StarterCharacterScripts.

-- Gradually regenerates the Humanoid's Health over time.

local REGEN_RATE = 1/100 -- Regenerate this fraction of MaxHealth per second.
local REGEN_STEP = 1 -- Wait this long between each regeneration step.

--------------------------------------------------------------------------------

local Character = script.Parent
local Humanoid = Character:WaitForChild('Humanoid')

--------------------------------------------------------------------------------

while true do
while Humanoid.Health < 80 do
local dt = wait(REGEN_STEP)
local dh = dt*REGEN_RATE * Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
Humanoid.HealthChanged:Wait()
end


Upvote / Accept if this helped you. :)

0
popeeyy 448
11 months ago

First, you may want to add something to your game like a health regen pad so it doesn't infinitely give health, otherwise they're "godded".

Here's a script that may work if they step on a regen pad:

--Health REGEN PAD

local db = false

script.Parent.Touched:connect(function(part)
if part.Parent and part.Parent:FindFirstChild'Humanoid' and not db then
db = true
local health = part.Parent.Humanoid.Health
if health >= 80 then
health = 100
else
health = 80
end
wait(1)
db = false
end
end)


The db variable is debounce so it doesn't give them too much health by just standing on the pad.

0
if mean automatic regeneration. Thanks anyway. :) blocky010101 2 — 11mo
0
*i not if blocky010101 2 — 11mo