How can I make this work for Unions so not only parts will be welded?
local prev local parts = script.Parent:GetChildren() for i = 1,#parts do if (parts[i].className == "Part") then if parts[i].Name ~= "Part" then if (prev ~= nil)then local weld = Instance.new("Weld") weld.Part0 = prev weld.Part1 = parts[i] weld.C0 = prev.CFrame:inverse() weld.C1 = parts[i].CFrame:inverse() weld.Parent = prev end prev = parts[i] end end end for i = 1,#parts do if (parts[i].className == "Part") then if parts[i].Name == "Left Leg" or parts[i].Name == "Right Leg" then parts[i].CanCollide = true end if parts[i].Name ~= "Part" then parts[i].Anchored = false end end end
In order to get this to work, you just need to check if the parts are BaseParts or UnionOperations (The ClassName for Unions).
The following would replace lines 4 and 19 in your code block:
if (parts[i].ClassName == "BasePart") or (parts[i].ClassName == "UnionOperation") then