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

Is there a way to respawn dummies? I've done this before but I don't remember how

Asked by 5 years ago

Hello, I'm creating a shooting range and there are moving dummies inside it, and I'd like them to respawn after they have died, is there a way to respawn them? I tried using LoadCharacter but that only applies to Player. A response would be great, thanks!

1 answer

Log in to vote
0
Answered by 5 years ago
local NPC = script.Parent
local Humanoid = NPC:WaitForChild("Humanoid")

Humanoid.Died:Connect(function()
    local NewNPC = game.ReplicatedStorage.Dummy:Clone()
    NewNPC.Parent = workspace
    NewNPC.HumanoidRootPart.Position = Vector3.new(X,Y,Z)
    NPC:BreakJoints()
    spawn(function()
        wait()
        NPC:Destroy()
    end)
end)

Where it says: NewNPC.HumanoidRootPart.Position = Vector3.new(X,Y,Z) change X,Y, and Z to your choice. If you want it to spawn in a random position, do NewNPC.HumanoidRootPart.Position = Vector3.new(math.random(-X,X),Y,math.random(-Z,Z))

Ad

Answer this question