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

Why do my NPCs keep dying?

Asked by
Dom2d2 35
10 years ago

Hey guys, here's my script.

while true do
    shed = game.ServerStorage.Shedletsky:Clone()
    shed.Parent = game.Workspace
    shed:MoveTo(Vector3.new(math.random(-512,512), math.random(50,325), math.random(-512,512))) 
    --game:GetService("Debris"):AddItem(shed, 5)
    wait(1)
end

Things are pretty straight-forward, except Shedletsky keeps dying when I move him. i don't get any errors. You can test this by inserting a NPC with a humanoid into ServerStorage and naming it Shedletsky.

1 answer

Log in to vote
2
Answered by
Sublimus 992 Moderation Voter
10 years ago

You need to use :MakeJoints() to keep the character together:

while true do
    shed = game.ServerStorage.Shedletsky:Clone()
    shed.Parent = game.Workspace
    shed:MakeJoints()
    shed:MoveTo(Vector3.new(math.random(-512,512), math.random(50,325), math.random(-512,512))) 
    --game:GetService("Debris"):AddItem(shed, 5)
    wait(1)
end

0
Thank you! Dom2d2 35 — 10y
0
No problem. Sublimus 992 — 10y
Ad

Answer this question