Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 2 years ago

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

0
Perhaps don't initialise dt on line 29? radiant_Light203 1166 — 2y
0
its just a wait monsterdanger16 13 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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

0
Not working monsterdanger16 13 — 2y
Ad

Answer this question