Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to weld tools that won't break? [closed]

Asked by 10 years ago

This question already has an answer here:

Help me with tool welds breaking?

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()
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. duckwit 1404 — 10y

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?

1 answer

Log in to vote
0
Answered by
Vathriel 510 Moderation Voter
10 years ago

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.

Ad