Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop hp from reverting back to 100 when damaged?

I made custom hp and hp regen but whenever the player gets damaged their health gets reverted back to 100 and damaged. Before it wasnt healing them back to maxhp so I made my own regen.

how fix? Code:

local Plr = game.Players.LocalPlayer
local Char = Plr.Character
local Hum = Char.Humanoid
local HumRoot = Char.HumanoidRootPart



local Health = 145
local Regen = 2 -- Health gained per regen rate
local Walk = 25
local Run = 2.25
local JumpPower = 65
local Defense = 15/100
local REGEN_STEP = 0.5 -- Wait this long between each regeneration step.
	
Hum.MaxHealth = Health
Hum.Health = Health
Char.Health:Destroy()

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

local Character = Char
local Humanoid = Character:WaitForChild'Humanoid'

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

while true do
	while Humanoid.Health < Humanoid.MaxHealth do
		local dt = wait(REGEN_STEP)
		Humanoid.Health += Regen
	end
	Humanoid.HealthChanged:Wait()
end

2 comments

0

Perhaps don't initialise dt on line 29?

0

its just a wait

1 answer

Put a empty script in StarterCharacterScripts, then, rename the script "Health".

1 comment

0

Not working

This discussion is preserved as it was. New answers, comments, and votes are closed.