I'm working on limiting players' health in my game to prevent it from regenerating over time by default. Is there an easy method or property I can change to do this, or will I have to write some crazy script that records the current health and manually keeps it at that level?
✓ ANSWER ACCEPTED
Preventing Health Regeneration? [Solved]
1 answer
✓ Accepted answer
There is a script in every player named 'Health' that manages regeneration, shown below:
--Responsible for regening a player's humanoid's health
-- declarations
local Figure = script.Parent
local Head = Figure:WaitForChild("Head")
local Humanoid = Figure:WaitForChild("Humanoid")
local regening = false
-- regeneration
function regenHealth()
if regening then return end
regening = true
while Humanoid.Health < Humanoid.MaxHealth do
local s = wait(1)
local health = Humanoid.Health
if health > 0 and health < Humanoid.MaxHealth then
local newHealthDelta = 0.01 * s * Humanoid.MaxHealth
health = health + newHealthDelta
Humanoid.Health = math.min(health,Humanoid.MaxHealth)
end
end
if Humanoid.Health > Humanoid.MaxHealth then
Humanoid.Health = Humanoid.MaxHealth
end
regening = false
end
Humanoid.HealthChanged:connect(regenHealth)
All you need to do is delete this script when a player respawns or spawns! To do this, insert this into a LocalScript in StarterGui:
game.Players.LocalPlayer.Character.Health:Destroy()
No crazy scripting involved! Hope I've helped! If you need any help, please comment, I'd be glad to fix your script or answer any questions.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Ahh, ok thanks, and messing with that doesn't have any other strings attached to worry about?
None at all, but you should know that it's better practice to use Debris:AddItem() to destroy members of spawning Characters, as they have a tendency to not actually get destroyed otherwise.