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 statsFolder = Character:WaitForChild("Stats")
local Humanoid = Character:WaitForChild'Humanoid'
--------------------------------------------------------------------------------
while true do
while Humanoid.Health < Humanoid.MaxHealth and statsFolder.inCombat.Value == false 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```
#healing script
16 messages · Page 1 of 1 (latest)
what is the problem?
try this: -- 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 statsFolder = Character:WaitForChild("Stats")
local Humanoid = Character:WaitForChild'Humanoid'
while true do
if Humanoid.Health < Humanoid.MaxHealth and statsFolder.inCombat.Value == false then
local dt = wait(REGEN_STEP)
local dh = dtREGEN_RATEHumanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
Humanoid.HealthChanged:Wait()
end
when the inCombat value is true its needs to stop healing
its not working
** You are now Level 4! **
Found the issue: It keeps running without properly checking incombat value each iteration.
Fixed code: ```lua
-- 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 statsFolder = Character:WaitForChild("Stats")
local Humanoid = Character:WaitForChild("Humanoid")
while true do
while Humanoid.Health < Humanoid.MaxHealth do
if statsFolder.inCombat.Value then
break
end
local dt = wait(REGEN_STEP)
local dh = dt * REGEN_RATE * Humanoid.MaxHealth
Humanoid.Health = math.min(Humanoid.Health + dh, Humanoid.MaxHealth)
end
local healthChangedConnection = Humanoid:GetPropertyChangedSignal("Health"):Connect(function() end)
local inCombatChangedConnection = statsFolder.inCombat.Changed:Connect(function() end)
wait()
healthChangedConnection:Disconnect()
inCombatChangedConnection:Disconnect()
end
** You are now Level 1! **
not workin
wellp
try using the script in a different place, maybe some other script is fucking it up
👍🏿