local function weldBetween(a, b) --Make a new Weld and Parent it to a. local weld = Instance.new("ManualWeld", a) weld.Part0 = a weld.Part1 = b --Get the CFrame of b relative to a. weld.C0 = a.CFrame:inverse() * b.CFrame --Return the reference to the weld so that you can change it later. return weld end local weld = weldBetween(script.Parent.Handle, script.Parent.Part1, script.Parent.Part2, script.Parent.Part3, script.Parent.Part4, script.Parent.Part5, script.Parent.Part6)
I'm making a tool with multiple parts, and this is my weld script, but it still does nothing. Only the Handle shows up. Help?
The problem is that you are passing too many arguments to the function weld
.
Instead, let's create a helper function that welds all the arguments together!
Here is my solution, with your code included:
local function weld(a, b) --Make a new Weld and Parent it to a. local weld = Instance.new("ManualWeld", a) weld.Part0 = a weld.Part1 = b --Get the CFrame of b relative to a. weld.C0 = b.CFrame:inverse() * a.CFrame --Return the reference to the weld so that you can change it later. return weld end local function weldBetween(...) local parts = {...} -- A list of all the arguments passed to this function local rootPart = parts[1] -- The first argument passed is going to be the part we weld everything to for a = 2, #parts do -- Weld all other parts to the first part weld(rootPart, parts[a]) end end local welds = weldBetween(script.Parent.Handle, script.Parent.Part1, script.Parent.Part2, script.Parent.Part3, script.Parent.Part4, script.Parent.Part5, script.Parent.Part6)