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

When my NPC die, why does walk script stop,help ?

local Model = script.Parent local Backup = Model:clone()

function Respawn() Model:breakJoints()

wait(5)

script.Parent = Model.Parent

Model:remove()
Model = Backup:clone()
Model.Parent = script.Parent
Model:makeJoints()

script:remove()

end

Model.Humanoid.Died:connect(Respawn)

2 comments

0

This is respawn script

0

No, it is a free model script

1 answer

I'm not 100% sure what you're trying to accomplish, nor the structure you are working with. So my answer may be somewhat generic, but it's to my interpretation of your question.

local Model = script.Parent
local Backup = Model:clone()

function Respawn()
	Model:BreakJoints()
	wait(5)
	
	Backup.Parent = script.Parent.Parent --Puts the backup where the current model is.
	Backup:makeJoints()
	
	Model:Destroy()
		
	script:Destroy()
end

Model.Humanoid.Died:connect(Respawn)

1 comment

0

:connect() is deprecated use Connect()

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