Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Having troubles with humanoid's being invincible. Any help?

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! :)

1 comment

0

You have to change the weapons.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.