So, I am writing a weld script for my rollercoaster car, and I will be able to use it for everything else. Anyway, It works, but for some reason, every piece go all weird, into weird places, but only on certain parts, not every piece. The code:
function weld(base, group) for i, v in pairs(group:GetChildren()) do if v ~= script.Parent.Welds then local w = Instance.new("ManualWeld") w.Parent = base w.Part0 = base w.Part1 = v w.C0 = (base.CFrame-v.Position) end end end weld(script.Parent.Brake, script.Parent)
I am not sure what is wrong... Any solutions, maybe?
here use this weld script i use it all the time :)
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() script:Remove()