How to weld two parts together, but leave the one's CFrame alone?

Hey, so I’ve been struggling trying to figure out why my code isn’t working. This is the formula I used for my other game, which works good, but for whatever reason all my pins keep welding in the center location of the part I’m welding them to, and they’re flipped at 180 degrees as well. I’m trying to weld the pins to this part so when the part moves they move as well, but I’d like for the pins to remain in the position that they’re in before they’re welded, if that makes sense.

Here’s the code I’m currently using:

for i,v in pairs(pins) do
	local w ="Weld", v)
	w.Part0 = v
	w.Part1 = pinsetter.Parent
	w.C1 = pinsetter.Parent.CFrame * v.CFrame:Inverse()
	v.CanCollide = false
	table.insert(welded_pins, v)

Thanks for reading!


“WeldConstraint” is whats keeping me from going insane whenever doing welding


I see…could you tell me what you mean by that??


instead of using the “Weld” thing, you use something called “WeldConstraint”, as i understand it it welds parts to other parts, like weld, but unlike weld, they stay in the same place when being welded (at least thats how i understand it)


That’s interesting. Will have to test it out and see if that fixes this, thanks!

Ayy I was doing this yesterday! You have to set the C0 or C1 before setting the Part0 and Part1. This is because the C0/C1 are empty CFrames to start, so Part1 attaches to the center of Part0. By setting the C0/C1 first, the parts will still be offset from each other. Here’s what I did:

Weld.C0 = A.CFrame:Inverse() * B.CFrame
Weld.Part0 = A
Weld.Part1 = B

There’s also a bug(?) with welds when using your method, if one of the parts is anchored it welds them with the centers together.

1 Like