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
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.
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.
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
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.