Log in to vote
1

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

Asked by 7 years ago

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

0
You have to change the weapons. NotsoPenguin 705 — 7y

1 answer

Log in to vote
1
Answered by
AxeOfMen 434 Moderation Voter
7 years ago

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.

Ad

Answer this question