ChildRemoved `child` parameter returning empty model

I’m currently making a Ragdoll System…
What I’m doing is checking if a troop/boss will be deleted using ChildRemoved

CurrentBoss.ChildRemoved:Connect(function(child: Instance)
	RagdollManager.SetRagdoll(child)
end)

Troops.ChildRemoved:Connect(function(child: Instance)
	RagdollManager.SetRagdoll(child)
end)

When ChildRemoved gets fired, the ragdoll manager puts the child inside a folder called RagdollContainer. But when checking the container, the models are all empty and due to that, the ragdolls does not work.

This is just the cloning process for the model/entity.

function Ragdoll.SetRagdoll(entity: Model)
	-- Make sure the entity hasn't been deleted/destroyed yet.
	if entity == nil then return end
	
	local newEntity = entity:Clone()
	newEntity.Parent = Ragdoll.Container or workspace
	local parts = newEntity:GetDescendants()

Check a few things:

  1. Do you have Archivable enabled on your descendants?
  2. Are you cloning before or after destroying?

Firstly, yes, the descendants are Archivable. And secondly, I’m not sure if ChildRemoved gets fired immediately after the Instance gets destroyed or before it gets destroyed.

ChildRemoved fires after you destroy the instance, because :Destroy() sets all descendants’ parents to nil, the Instance will have no descendants.

1 Like