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

How can I fix this weld?

Asked by 6 years ago
Edited 6 years ago

I'm trying to weld many objects to one. Code here:

local function addWeld(folder, part)
    local weld = Instance.new("ManualWeld")
    weld.Parent = part
    if not folder then
        weld.Part0 = part.Parent.Chassis
    else
        weld.Part0 = part.Parent.Parent.Chassis
    end
    weld.Part1 = part
    weld.C0 = part.CFrame * CFrame.new(0, 0, 0)
    if part.Name ~= "Base" then
        part.Anchored = false
    end
end

for i,v in pairs(workspace.Banshee:GetChildren()) do
    if v:IsA("Folder") then
        for j,w in pairs(v:GetChildren()) do
            addWeld(true, w)
        end
    elseif v.Name ~= "Chassis" then
        addWeld(false, v)
    end
    workspace.Banshee.Chassis.Anchored = false
end

All of it seems to work except for the final line workspace.Banshee.Chassis.Anchored = false. This causes the Chassis part to jump to the 0 position on all axes. Any idea what's going on?

Answer this question