Respawn Script not working

So i’m trying to make a stupid respawn script for my mob, but guess what, it doesn’t work =)
Why? I don’t know. It prints "Died." but stops printing after the wait(5).
I don’t see anything wrong with the script. I tried different types of respawn scripts. I even took the one from my other game (which was working) but not on this dummy.

Note: my dummy is R6. (Idk if that matters, but there you go)

Any help is appreciated, thanks!

image

2 Likes

Instead of Copy.Parent = NPC.Parent make Copy.Parent = NPC
and where is the Parent of Copy:MakeJoints()?
I dont understand ur Code what are u trying to do

1 Like

Try this:

local Copy = script.Parent:Clone()
local NPC = script.Parent
local Humanoid = NPC:WaitForChild("Humanoid")

while wait(0.001) do
      if Humanoid.Health == 0 then
           print("Died.")
           wait(5)
           Copy:Destroy()
      end
end
1 Like

If the humanoid gets deleted then the script will break, you could connect to both the Died event and the Destroying events to account for any mob death!

local connection
connection = humanoid.Died:Connect(function()
     Clone.Parent = workspace
     connection:Disconnect()
end)
connection = humanoid.Destroying:Connect(function()
     Clone.Parent = workspace 
     connection:Disconnect()
end)
1 Like