How do i make an npc respawn after 5 seconds

Try this one:

local humanoid= script.Parent:WaitForChild("Humanoid")
local robo = script.Parent
humanoid.Died:connect(function()
wait(5)
local robo1 =robo:Clone()
robo1.Parent=game.Workspace
robo1:makeJoints()
script.Parent:Destroy()
end)
1 Like


stil doesnt

I think i misspell makeJoint() it should be like this MakeJoints()

Re copy it again:

local humanoid= script.Parent:WaitForChild("Humanoid")
local robo = script.Parent
humanoid.Died:connect(function()
wait(5)
local robo1 =robo:Clone()
robo1.Parent=script.Parent.Parent
robo1:MakeJoints()
script.Parent:Destroy()
end)

stil nothing
could it be intefering with one of the other scripts

No its not script can’t interfering with each other looks like i can’t help you more than that now

Add a Print Statement to see whether the code is running or not.


like this cuz i dont get a print statement

put the print statement in quotation marks. Like this:

print("Respawn Script Activated!")


its the wait that doesnt work

Are you sure that you’re waiting 5 seconds? It should work.

yes, you can see the time of my pc i waited around 15 sec

I don’t know what’s happening. Instead of that, try this:

local humanoid= script.Parent:WaitForChild("Humanoid")
local robo = script.Parent
humanoid.Died:connect(function()
print("respawning")
delay(5, function()
print("waited 5 secs")
local robo1 =robo:Clone()
robo1.Parent=script.Parent.Parent
robo1:MakeJoints()
script.Parent:Destroy()
end)
end)


nope my roblox studio just does not want to work

Hold on, try removing the delay and see if it works. The problem might be that roblox can’t find the humanoid. Also remove one end)


now this is happening

Alright, I have an idea. How about you clone the humanoid before they die, and then clone the cloned humanoid when they die?

and how would i do that (text)

local humanoid= script.Parent:WaitForChild("Humanoid")
local robo = script.Parent
local roboClone = robo:Clone()
humanoid.Died:Connect(function()
print("Respawning...")
wait(5)
print("Respawning...")
local robo1 =roboClone:Clone()
robo1.Parent=script.Parent.Parent
robo1:MakeJoints()
script.Parent:Destroy()
end)
2 Likes

it dies but it does not respawn