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

Making a script that Welds all parts connected to a certain piece ?

Asked by 10 years ago

I want to make Planes and Cars for my siblings And i dont want to have to weld all the Parts i use to the car. I'm still learning how to script...

local weldTo = script.Parent.Functions.Engine
local weldToCf = weldTo.CFrame:inverse()
local parts = (weldTo)
function weld(parent)
    for _,v in pairs(parent:GetChildren())do
        if (v:IsA("BasePart")and v ~= weldTo)then
            local w = Instance.new("Weld")
            w.Name = "PlaneWeld"
            w.Part0 = weldTo
            w.Part1 = v
            w.C0 = weldToCf
            w.c1 = v.Cframe:inverse()
            w.Parent = weldTo
            table.insert(parts, v)
        end
        Weld(v)
    end 
end

Weld(script.Parent)

for _,v in pairs(parts) do
    v.Anchored = false
end

script:Destroy()

I watched Crazyman32's Tutorial vid on making a plane on Youtube....DIdnt work

Answer this question