Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

2 comments

0

Thanks. This has happened with a different type of script, I should have learned my lesson, haha.

0

No problem. Glad I could be of service.

This discussion is preserved as it was. New answers, comments, and votes are closed.