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

Can someone help me fix my script?

Asked by
red106 0
10 years ago

This is my respawn script, I put it in a model I need to respawn when it dies but when I put the wait time over 1 second the script doesn't work. Can someone help me ?

name="Humanoid"

robo=script.Parent:clone()

while true do
    wait(1)
    if script.Parent.Humanoid.Health<1 then
        robot=robo:clone()
        robot.Parent=script.Parent.Parent
        robot:makeJoints()
        script.Parent:remove()
    end
end



2 answers

Log in to vote
0
Answered by
Bebee2 195
10 years ago

robo on line 3 should be robot

Ad
Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
10 years ago

Use the died event for this.

robo = script.Parent:clone()
script.Parent.Humanoid.Died:connect(function()
    robot = robo:clone()
    robot.Parent = script.Parent.Parent
    robot:MakeJoints()
    script.Parent:remove()
end)

Answer this question