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

Can someone help troubleshoot my :MoveTo()/Respawning Dummy script?

Asked by 9 years ago

So I have this script that when a humanoid dies, it the same model from ServerStorage, and puts it in the same place the old one was (It is a respawning dummy by the way)

What is puzzling me is that it works 1 or 2 times, but then it just teleports them to the center of the baseplate, here is the script.

hum=script.Parent
model=hum.Parent
dummy=hum.Parent.Torso

pos=dummy.Position

function clone()
    dum=game.ServerStorage:FindFirstChild("Dummy")
    dumclone=dum:Clone()
    dumclone.Parent=game.Workspace
    dumclone:MoveTo(pos)
    dumclone.Humanoid.Script.Disabled=false
    model:Destroy()
end




hum.Died:connect(function()
    clone()

end)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

I suggest moving line 3-5 after the Died event, but before the clone function is called. The reason for this is that creating the variable before the humanoid dies will eventually have the position outdated. So, here's the script.

hum=script.Parent
model=hum.Parent

function clone()
    dum=game.ServerStorage:FindFirstChild("Dummy")
    dumclone=dum:Clone()
    dumclone.Parent=game.Workspace
    dumclone:MoveTo(pos)
    dumclone.Humanoid.Script.Disabled=false
    model:Destroy()
end




hum.Died:connect(function()
    dummy=hum.Parent.Torso
    pos=dummy.Position
    clone()

end)

0
Thanks. This has happened with a different type of script, I should have learned my lesson, haha. Tempestatem 884 — 9y
0
No problem. Glad I could be of service. Shawnyg 4330 — 9y
Ad

Answer this question