I’m not very experienced with coding, but what I wanted to do was make my Health Regen script wait about 7 seconds and then heal rapidly.
The problem is that I can lose health, but I can’t regenerate health at all. I would take fall damage and wait the seconds I put in, but nothing would happen afterwards. If there’s anything I did wrong in the script, please tell me.
local character = game.Players.LocalPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local maxhp = Humanoid.MaxHealth
Humanoid.HealthChanged:Connect(function()
print("health Changed")
wait(7)
print("healing")
repeat
Humanoid.Health = Humanoid.Health + 5
wait(0.5)
until hp >= maxhp
end)
In the script on line 12 I believe you mention something called hp. However nowhere in the script does it show you defined something called hp. Consider also changing maxhp to 100 instead of getting the MaxHealth number.
local character = game.Players.LocalPlayer.Character
local Humanoid = character:WaitForChild("Humanoid")
local maxhp = Humanoid.MaxHealth
Humanoid:GetPropertyChangedSignal("Health"):Connect(function()
print("Health changed")
task.delay(7, function()
print("healing")
while Humanoid.Health < maxhp do
task.wait(0.5)
Humanoid.Health += 5
end
end)
end)
I put in this script, and I was able to regenerate health. The only problems now are that it won’t heal the amount I put in and it won’t wait the 7 seconds either.