RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a health regen script inside a npc that only generates when player isnt attacking the NPC"
-- script inside the NPC local humanoid = script.Parent:WaitForChild("Humanoid") local regenRate = 5 -- Health regenerated per second local regenDelay = 3 -- Delay before regenerating health local lastDamage = 0 local function regenHealth() while true do wait(1) if (tick() - lastDamage) > regenDelay and humanoid.Health < humanoid.MaxHealth then humanoid.Health = humanoid.Health + regenRate end end end local function onTakingDamage() lastDamage = tick() end humanoid.TakingDamage:Connect(onTakingDamage) spawn(regenHealth)