I wanted to add a delay before a player could be able to heal for my game.
the issue is that i don’t know how i can restart the 3 second timer again if the player get hit again before the 3 second ends.
for example if you get hit 2 times, you will regen for like half a second after the first hit then will be set to false again.`
I want the delay time to reset back to 3 seconds without you healing in between if you get hit a second or mutiple times within this delay time
here’s the script:
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local oldHealth = humanoid.Health
local damaged = Instance.new("BoolValue")
damaged.Name = "damaged"
damaged.Value = false
damaged.Parent = character
while wait() do
humanoid:GetPropertyChangedSignal("Health"):Connect(function()
local delayTime = 3
if humanoid.Health < oldHealth then
damaged.Value = true
wait(delayTime)
damaged.Value = false
end
oldHealth = humanoid.Health
end)
end