i dont really know how to script this, and the best solution ive found is to just have a fixed amount(e.g. player heals 1 health per second) instead of it increasing over time(e.g. player heals 1 health for 1 second, 1 health for 0.95 seconds etc… or 1 health for 1 second, 2 health for 1 second etc…)
searched for awhile but couldnt find any information on how to achieve this.
it would be much appreciated if you could provide the code for this if you do know how to script this.
2 Likes
You could create a value in the player called healmultiplier which goes up every 1 second. Whenever you increase hp you can multiply the amount added by this healmultiplier value.
1 Like
This seemed fun so i made it so that the healing speed accelerates
To do this, you just need to put a script named “Health” in StarterCharacterScripts:
and in that script just paste:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local RegenTime = 1 -- How fast you want the first health regen to start after taking damage
local RegenAmount = 1 -- How much hp player gets
local RegenTimeReduce = 0.05 -- How much it reduces the regentime each time
local MinimunRegenTime = 0.1 -- This is so that the healing doesnt become way too fast in the end, u can make it faster though, like 0.05
local OriginalRegenTime = RegenTime
local LastHealth = Humanoid.MaxHealth
Humanoid.HealthChanged:Connect(function(Health)
if Health < LastHealth then
RegenTime = OriginalRegenTime
end
LastHealth = Health
end)
while true do
while Humanoid.Health < Humanoid.MaxHealth do
wait(math.max(RegenTime,MinimunRegenTime))
RegenTime = math.max(RegenTime - RegenTimeReduce,RegenTimeReduce)
Humanoid.Health = math.min(Humanoid.Health + RegenAmount, Humanoid.MaxHealth)
end
RegenTime = OriginalRegenTime
Humanoid.HealthChanged:Wait()
end
1 Like
seems to be working as intended, thank you!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.