Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to spawn NPCs without killing them?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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
0
Thanks so much! alonzo12345 60 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

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!

Answer this question