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

How to spawn NPCs without killing them?

Okay, so, I made a room with a button in the middle of it. When you touch the button, it's supposed to spawn 1 NPC in each corner of the room. I put the NPCs in Lighting and just use :Clone() to copy them into workspace. Thing is, they spawn with 0 health, and they die. How can I spawn them without them dying?

2 answers

✓ Accepted answer

Here is a recommended fail safe version... Copied from BlackOrange but added something

local NPC = game.Lighting:WaitForChild("NPC NAME HERE")

NPC:FindFirstChild("Humanoid").MaxHealth = 100
NPC:FindFirstChild("Humanoid").Health = 100
NPC:MakeJoints() -- Very important line <3

1 comment

0

Thanks so much!

Here is a list of things you can try:

You can check by looking at the NPC in lighting. Look for it's Humanoid and go down and change it's health.

You can check if anything is making them go 0 health. (Kill bricks etc.)

You can change the NPC's health through a script, in this case add a script to ServerScriptService and insert this code:

local NPC = game.Lighting:WaitForChild("NPC NAME HERE")

NPC:FindFirstChild("Humanoid").MaxHealth = 100
NPC:FindFirstChild("Humanoid").Health = 100

Or you can add this on to the Clone script.

Try these and post any comments, errors or any questions.

Please accept answer and Upvote if helped!

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