Welds break after cloning model

So basically I am trying to convert a model into a tool, which should be pretty simple.
This is my code:

--I have a variable for the model and player already.
local tool = Instance.new('Tool')

for _, child in pairs(model:GetChildren()) do
		print('Cloning '.. child.Name)
		child:Clone().Parent = tool
	end
tool.Parent = plr.Backpack

It converts the model to a tool just fine, but when I try equipping the tool, the parts aren’t welded to eachother. I can only see 1/2 parts in the tool, the second part isn’t visible (i am guessing it fell into the void)

Thanks for any help!

2 Likes

Can’t you just clone the model itself?

local clone = model:Clone()
clone.Parent = tool

If your tool requires a handle, then the handle can’t be inside of the model.

2 Likes

That wouldn’t work for me, since I don’t want an unnecessary model inside of the tool. Also, this wouldn’t solve my weld problem.

2 Likes

Due to you cloning each part individually and sequentially, the welds inside the cloned parts would have no reference to the non-cloned parts yet.

So what I would do is clone the model then parent the parts inside the cloned model to the tool.

local tool = Instance.new('Tool')

local modelClone = model:Clone()
for _, child in pairs(modelClone:GetChildren()) do
	child.Parent = tool
end
tool.Parent = plr.Backpack
modelClone:Destroy() -- Prevents memory leaks.
3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.