I am creating a NPC I'm having the problem that it's currently invincible. I ripped my coding out from another NPC and replaced some things (I hardly have any idea what I'm doing) and didn't seem to get it to work.
The Humanoid is named NPC.
function waitForChild(parent, childName) while true do local child = parent:findFirstChild(childName) if child then return child end parent.ChildAdded:wait() end end -- declarations local Figure = script.Parent local Head = waitForChild(Figure, "Head") local Humanoid = waitForChild(Figure, "NPC") -- regeneration while true do local s = wait(4) local health = Humanoid.Health if health > 0 and health < Humanoid.MaxHealth then health = health + 0.08 * s * Humanoid.MaxHealth if health * 1.05 < Humanoid.MaxHealth then Humanoid.Health = health else Humanoid.Health = Humanoid.MaxHealth end end end
Help would be greatly appreciated! :)
This script is a health regen script. If you want the NPC to not regen health, delete this script and it won't regen anymore. If it's regenerating too fast for your taste, change 0.08
to something smaller.