Help with npc respawning


for i,v in pairs(MobIndexer) do
	local npc = v.MobModelLocate:FindFirstChild(tostring(v.Name))
	print(tostring(npc.Name))
	npc:FindFirstChild("Humanoid").Died:Connect(function()
		task.wait(1)
		local clonedmob = 	game.ReplicatedStorage.Mobs:FindFirstChild(npc.Name):Clone()
		clonedmob.Parent = v.MobModelLocate
		clonedmob:FindFirstChild("HumanoidRootPart").Position = npc:FindFirstChild("HumanoidRootPart").Position
		
		local newmob = MobModule.Ui(v)
		
		npc = v.MobModelLocate:FindFirstChild(tostring(v.Name))
		wait(0.2)
		npc:Destroy()

	end)
	local newmob = MobModule.Ui(v)
	
end

my npc only respawns once and then does not after? why? could anybody help with this

youre not checking if the respawned npc died.


local Init = function(Hum, Indexer)
    Hum.Died:Connect(function()
        task.wait(1)

        local NewMob = game:GetService("ReplicatedStorage").Mobs[Hum.Parent.Name]:Clone()
        NewMob.Parent = Indexer.MobModelLocate 
        NewMob.HumanoidRootPart.CFrame = Hum.Parent.HumanoidRootPart.CFrame

        Init(NewBob.Humanoid, Indexer) 

        MobModule.Ui(Indexer)

        task.wait(0.2)

        Hum.Parent:Destroy()
    end)
end


for i,v in pairs(MobIndexer) do 
    MobModule.Ui(v)
    
    Init(v.MobModelLocate[tostring(v.Name)].Humanoid, v) 
end

it returns this error