local h = script.Parent local g = script.Parent.Parent local hm = nil for i,v in pairs (g:GetChildren()) do if (v ~= h) and (v.ClassName == "Part") then v.Name = "Part"..i-1 hm = i end end wait(1) for i=1,hm do p = g["Part"..i] P0 = CFrame.new(h.Position.X,h.Position.Y,h.Position.Z) P1 = CFrame.new(p.Position.X,p.Position.Y,p.Position.Z) w = Instance.new("Weld", h) w.C0 = P0 w.Part0 = h w.C1 = P1 w.Part1 = p end
So, what this does is that it automaticly welds multiple parts, without doing to much writing over the script. But theres a small problem, the parts keeps bugging around. How do i fix this?
Ah, yes, complicated welds. :)
I have found (any many others have, too) that this is the simplest way to position parts correctly using an auto welder:
weld.C1 = part1.CFrame:inverse() * part0.CFrame
You don't even have to set the C0, if you don't want to!
You could think of the C0 property as a position and rotation set relative to the Part0, and the C1 as how far away and rotated is Part1 from the position and rotation set in the C0.
Lets say a part was at 0, 0, 0 (our Part0) and the Part1 is located at 0, 5, 0. If the C0 is CFrame.new() or CFrame.new(0, 0, 0), then the relative position is AT Part0's CFrame. This means that the C0 is 0, -5, 0 away from Part1, so the C1 would be CFrame.new(0, -5, 0)
Does that make sense? I tried simplifying my explanation to make more sense. :P