Cloned tool's children returns 0

local function clone_tool_model(tool : Tool)
	local cloned_tool = tool:Clone()
	local model = Instance.new("Model")
	
	repeat task.wait() warn("Children <= 0") until #cloned_tool:GetChildren() > 0
	
	for _, obj in pairs(cloned_tool:GetChildren()) do
		obj.Parent = model
	end
	
	cloned_tool:Destroy()
	return model
end

Output:
image

How do I fix this?

You don’t include much details in your post. Is this a server script or localscript? Depending on whether it’s a localscript or server script, try seeing what’s inside the tool from that perspective.

This is a local script, I looked into the returned model from the explorer, I see that the model has no children

Ah, are there multiple parts in your tool?

The original tool has multiple parts

Do you have a “Handle” inside of your tool? Does your tool have the require handle property checked?

Yes, it does have a Handle, the require handle property is checked

What I assume is happening is since there’s multiple parts in your tool, the parts are falling out into the void because they’re not welded together or in some sort of “group” like a union, mesh, etc.

By the way, I have looked into this post:

I can’t understand what the solution is saying

There are WeldConstraints inside the Handle connecting to every part in the tool

What it’s saying is that instances don’t yield. Yield means that the code stops until whatever it’s doing is completed.

Since this also applies to cloning because you’re basically creating a new instance just with the same children and properties, right when you call to clone your tool it does that check that you implemented to see whether or not the amount of children is greater than 0.

It means that a script’s execution is instant. If you don’t call for a WaitForChild, the script will instantly clone the instance before its children can be created.

Cloning usually don’t take that long to complete, I made a loop to stop whenever the cloned tool’s children is greater than 0, the loop lasted forever
image

I am trying to clone every cloned tool’s object and put it in a model, how would I use :WaitForChild in this case?

That is true, but the problem with their code is that they’re constantly doing a check to see if the amount of children is greater than 0, but the tool should keep being created while that loop is running. Unless I’m missing something, I don’t believe that’s exactly the root cause.

Keep in mind that this is how the uncloned tool look like:
image

Have you tried setting the clone’s parent to a service like Workspace?

You can try waiting for the parent to load first:

local tool = --blahblahblah:WaitForChild("Your tool")
local cloned_tool = tool:Clone()

Do a check if the tool exists and then loop through its children and parent them.

Edit: Just saw your uncloned tool, that’s a whole lot of children.

Nope, I will try to do that now