function Respawn()wait(RESPAWN_DELAY)CurrentFigure:Destroy()CurrentFigure=Figure:Clone()CurrentFigure:MakeJoints()CurrentFigure.Parent=Model CurrentFigure.Humanoid.Died:connect(onDied)end function onRemoved(I)if I==CurrentFigure and CanSpawn then Respawn()end end function onDied()if CanSpawn then CanSpawn=false Respawn()CanSpawn=true end end CurrentFigure.Humanoid.Died:connect(onDied)
-- This check exists to prevent an infinite respawning bug

function Respawn()
	wait(RESPAWN_DELAY) -- ya

	CurrentFigure:Destroy()
	CurrentFigure = Figure:Clone()
	CurrentFigure:MakeJoints()
	CurrentFigure.Parent = Model
	-- Destroy the current dummy, clone the extra, put it together, and put it inside of Model

	CurrentFigure.Humanoid.Died:connect(onDied)
	-- Connect the Died event on the new dummies Humanoid, it will fire the Died() function below when it dies
end
function onRemoved(Object)
	if Object == CurrentFigure and CanSpawn then
		Respawn()
	end
	-- Check if the object that was removed was the current dummy
	-- and if it is able to spawn a new one, if so, spawn a new one.
end
function onDied()
	if CanSpawn then
		CanSpawn = false
		Respawn()
		CanSpawn = true
	end
	-- Fire Respawn() function if CanSpawn is true and
	-- set CanSpawn to false while the function is running.
end

CurrentFigure.Humanoid.Died:connect(onDied)
