Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to weld tools that won't break?

Lately I've been trying to weld tools with small parts. When first equip the tool everything is fine and in place but when unequipped small parts are scattered everywhere and most of the welds break(some of them are still in place though).

I'm using this script to do the welding:

function weld()
	local parts,last = {}
	local function scan(parent)
		for _,v in pairs(parent:GetChildren()) do
			if (v:IsA("BasePart")) then
				if (last) then
					local w = Instance.new("Weld")
					w.Name = ("%s_Weld"):format(v.Name)
					w.Part0,w.Part1 = last,v
					w.C0 = last.CFrame:inverse()
					w.C1 = v.CFrame:inverse()
					w.Parent = last
				end
				last = v
				table.insert(parts,v)
			end
			scan(v)
		end
	end
	scan(script.Parent)
	for _,v in pairs(parts) do
		v.Anchored = false
	end
end

weld()

1 comment

0

I'm not sure if there is a more 'formal' solution to this, but when the same was happening to me (welds breaking when moving models in and out of Workspace) I found that re-welding it each time you move it to the workspace does the trick.

1 answer

✓ Accepted answer

Just call the function with equipped and unequipped events, also add a small wait() before you call the function as otherwise before the welds all break you will create extras which can cause the game to lag.

This discussion is preserved as it was. New answers, comments, and votes are closed.