Pyfro
(Pyfro)
April 3, 2021, 8:29am
1
hello everyone
i am trying to let my npc respawn after 5 seconds but if i add wait(5) in the script, it just does not respawn anymore. here is the code:
name=“Humanoid”
robo=script.Parent:Clone()
while true do
if script.Parent.Humanoid.Health<1 then
wait(5)
end
robo=robo:Clone()
robo.Parent=script.Parent.Parent
robo:makeJoints()
script.Parent:remove()
end
end
1.i want someone that explains to me why this does not work and how i can fix it
2.the isue is that it does not respawn and i want it to respawn after 5 seconds
3.i looked for a solution on the developer hub and i found one but it did not work for me
2 Likes
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:31am
2
Do it like this:
Local humanoid= script.Parent.Humanoid
humanoid.Died:connect(function()
Wait(5)
Local robo=robo:Clone()
robo.Parent=script.Parent.Parent
robo:makeJoints()
script.Parent:Destroy()
end)
1 Like
ShutzCh
(Shutz)
April 3, 2021, 8:33am
3
Use Destroy() instead of Remove(), for the rest you did it right.
1 Like
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:34am
4
Haha yes remove is deprecated thanks for letting me know
1 Like
Pyfro
(Pyfro)
April 3, 2021, 8:36am
5
do i need to place it in the npc or in the humanoid
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:38am
6
Put it In the NPC. Ignore this message because I need more word on this message because dev forum minimum character is bad
Pyfro
(Pyfro)
April 3, 2021, 8:43am
7
it does not respawn (text text text)
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:44am
8
Firstly is it a script it shouldn’t be a local script secondly did you put it in the NPC model itself or you put it in the Npc part if you are confuse where you put pls show me the workspace where the npc is and every of his stuff
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:55am
10
Okay its good but show me the script you’ve written
MrchipsMa
(MrchipsMan)
April 3, 2021, 8:57am
12
Okay my bad I didn’t write it correctly here try this one:
local humanoid= script.Parent.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)
Now it should work i fixed the script again
Pyfro
(Pyfro)
April 3, 2021, 8:59am
13
hmm stil does not work (text text)
MrchipsMa
(MrchipsMan)
April 3, 2021, 9:00am
14
I just edit the script try it again
MrchipsMa
(MrchipsMan)
April 3, 2021, 9:04am
16
Did you wait 5 sec after it died?
Pyfro
(Pyfro)
April 3, 2021, 9:05am
17
yes (text text text text text)
MrchipsMa
(MrchipsMan)
April 3, 2021, 9:07am
18
Okay wait 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=script.Parent.Parent
robo1:makeJoints()
script.Parent:Destroy()
end)
Also try opening the output and see if there is any error if that script i am giving you isn’t working
Pyfro
(Pyfro)
April 3, 2021, 9:12am
19
there is no error but it seems like the script does not get activated
MrchipsMa
(MrchipsMan)
April 3, 2021, 9:13am
20
Bruh you removed the Humanoid line in the script re copy that 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)