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()
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.
Marked as Duplicate by MrNicNac
This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.
Why was this question closed?