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!
01 | local NPC = script.Parent |
02 | local Humanoid = NPC:WaitForChild( "Humanoid" ) |
03 |
04 | Humanoid.Died:Connect( function () |
05 | local NewNPC = game.ReplicatedStorage.Dummy:Clone() |
06 | NewNPC.Parent = workspace |
07 | NewNPC.HumanoidRootPart.Position = Vector 3. new(X,Y,Z) |
08 | NPC:BreakJoints() |
09 | spawn( function () |
10 | wait() |
11 | NPC:Destroy() |
12 | end ) |
13 | 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))