Haven't ever used MS's before, so cut me some slack if I'm doing this all wrong.
ServerScript:
local weld = jar.WeldTo(root, c, v.Joints, 'relative') -- None of these arguments are nil
ModuleScript(named 'jar')
local jar = {} function jar.WeldTo(a, b, jfolder, cframe) local weld = Instance.new('Weld', jfolder) weld.Name = 'Weld' weld.Part0 = a -- Error: Bad Cast weld.Part1 = b if cframe == 'relative' then weld.C0 = a.CFrame:inverse() * b.CFrame else weld.C0 = cframe end return weld end return jar
Try this:
local jar = {} function jar.WeldTo(a, b, jfolder, cframe) if A:IsA("Part") and B:IsA("Part") then local weld = Instance.new('Weld', jfolder) weld.Name = 'Weld' weld.Part0 = a -- Error: Bad Cast weld.Part1 = b if cframe == 'relative' then weld.C0 = a.CFrame:inverse() * b.CFrame else weld.C0 = cframe end return weld] end end return jar
The reason why I added " if A:IsA("Part") and B:IsA("Part") then" is because if A or B is not a part, it will cause a cast error which means that you gave the script something that it is not looking for.