How do I make an npc of me that can't die?

I’m trying to make a shop npc of myself but the npc can be killed, even if it’s anchored.

1 Like

You should name your NPC’s Humanoid something other than “Humanoid”, something like “NPCHumanoid”, and in the script doing damage, you would check if the name is the name you set the NPC’s Humanoid to, if there even is one. Another point to consider, if the NPC isn’t moving, then it’s probably better that you don’t use a Humanoid

Simple way is set the health as high as possible in properties and make the heath display distance 0. Edit: I don’t remember exactly but you might have to click on the humanoid in the explorer.

I might be mistaken (though It sounds weird), setting all health properties (max health, health, etc) to 0 will allow the humanoid to not die and still play animations and etc. And if you want to be extra sure, add an invisible force field on the humanoid.

Or just add an invisible forcefield, that works as well I guess.

Set the humanoid’s MaxHealth to 0, and I don’t think it will die.

How do I add an invisible forcefield?

Inserting a forcefield into the character then going into properties and setting the .visible into false will work. However, if you also want, setting the health and max health to 0 works as well. (doing both is generally a good idea, it protects against both explosions and damaging.)

Sounds good. Where is the health and maxhealth stored?

Clicking the humanoid and opening properties then scrolling down near the bottom, you can find the maxhealth and health properties, set health first to 0, then maxhealth to 0.

1 Like

Keep in mind that forcefields only prevent damage from the Humanoid:TakeDamage() function, but you can still change the health with Humanoid.Health, so be aware that if you are changing the Humanoid’s Health property directly

Thank you! I hope they don’t end up dead lmao

It’s advised to do both as just setting the health to 0 wont prevent explosions from killing the npc.

You insert a ForceField instance into the part, and then edit the property “Visible” in the ForceField. If it isn’t visible, the ForceField will be invisible.

I tried setting the health and maxhealth to zero, but explosions still make the npc lose its head

As seen here, explosions still kill with health 0, adding forcefields helps prevent this issue as well.
https://gyazo.com/75e44f749e63033329f53d6804d2739a

Where do I add a forcefield? Humanoid?

Into the model itself, the character ,no humanoid. Inside the forcefield you can find the visible property, disable that.

EDIT:
https://gyazo.com/c573b9604ff049fae01c6c65a51eee6f

https://gyazo.com/8ed80567be46b41bf0bac8781422b877

Alright, that’s perfect. I’ll try now.

You can set alot of numbers, for example:

74947583836393927262894939393939393838933882282927252792926282929473892736492839283738299282648393938273838848747474938282929464829648492749393739028579492100128920402905857820107652

If you do that, the Value Will be automatically set to inf (infinite), so you can set MaxHealth to inf and later health. If you want to do that on a script, don’t write too much numbers or inf, You need to write something like this:

Humanoid.Health = math.huge()

You can write a script that checks if the NPC health have changed, make sure that the script is set in the NPC

local NPC = script.Parent
local Humanoid = NPC:FindFirstChild("Humanoid")

Humanoid.HealthChanged:Connect(function()
    Humanoid.Health = math.huge()
end)

I hope this help.

Alright, the best solution imo is to add the invisible forcefield. Thanks to everyone who responded, I love this community!