I’ve been puzzled about this for a while, but I’m really unsure if I should move to WeldConstraints or normal Welds.
I’ve been using Welds for a while (with the C0 being a ToObjectSpace() method) but WeldConstraints behave in the same way, just without any CFrame manipulation.
However, if it the ‘targ’ part is close to the ‘root’, using a WeldConstraint would do the exact same thing, except only 2 lines are removed (C0 and local offset).
If you want to let Roblox handle offsets (but have them fixed), use WeldConstraints.
If you want variable offsets, use Welds.
I made a module previously that uses WeldConstraints that essentially acts exactly like a Model for a weapon system as :SetPrimaryPartCFrame() was destroying the weapons/arms as time went on.
However, in hindsight, I should’ve just used plain Welds so it would’ve been more efficient.
You should always use WeldConstraint. It is newer and simpler, and at some point I suspect Weld will be deprecated. Here’s what the docs say about Weld… " See also WeldConstraint for a newer alternative using the constraints system that does not require C0 or C1 properties to be manually set."
I suppose you are correct, WeldConstraints are certainly more easier to work with and are more efficient overall.
However, Weld being deprecated would be unnecessary to say the least. Nowadays, welds are still used not only because of variable offsets that can be manually set whenever need be, but also because of familiarity.
I have made a module in the past that uses WeldConstraints instead of normal welds that act exactly like welds, but this would require a temporary destruction of the original constraint, positional update, and then reconstruction of the WeldConstraint. It’s for this reason I doubt Roblox will actually deprecate the Weld class.
WeldConstraints do both. They recalculate offsets if the part’s position changes, and maintain offsets if the CFrame is changed. From the docs…
" If a welded part’s Position is updated, the part will move but none of the connected parts will move with it. The weld will recalculate the offset from the other part based on the part’s new position. In contrast, if a part’s CFrame is updated, that part will move and any part welded to that part will also move. These other parts will be moved to make sure they maintain the same offset as when the weld was created."
Still, Weld deprecation wouldn’t be a good call on Roblox’s part. Dozens of thousands of games uses them. Yes, I know deprecation doesn’t disable the usage of the Instance, just hides them from typical Studio class insertion and an advisory to not use them.
Thanks.
I’ve always had a choice between using a WeldConstraint or a basic weld, but I primarily chose a basic weld.
I dont feel a difference, besides C0 and C1 automatically being managed. I made a magnet that joins parts on touch, and WeldConstraint vs Weld does the exact same thing.
It doesn’t mean you should completely stick to the newer version though, we all have our differences and if it’s absolutely necessary then you should move on.
Although, if you were to update the offset of a WeldConstraint, you’d have to reconstruct the entire thing by setting the CFrame and then re-welding. Besides a Weld or a Motor6D, you can just update the C0 property.
And if you were in this type of position, you should probably use a Weld or a Motor6D.