Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

(Answered) How can i weld two parts with saving their position?

Hello

I am trying to create a system that welds two parts between them. But I ran into a little problem. When welding, the parts will be placed in one position, but I do not need this, I need them to remain in the same position.

For example, there's two parts

Position of part 1 is 12,30,19

Position of part 2 is 93,29,13

When welded, those positions need to remain the same. Any help? I tryed to change position of part 2 when they were welded but it not seems to work properly.

1 answer

Since nobody answered my question, i got it myself.

You need to use CFrame:Inverse() on both of Weld.C0 and Weld.C1

It looks like this:

local weld = Instance.new("Weld")
weld.Part0 = part1
weld.Part1 = part2
weld.C0 = part1.CFrame:Inverse()
weld.C1 = part2.CFrame:Inverse()
weld.Parent = part1

You can learn more about those hard CFrames from those pages:

Understanding CFrames

https://developer.roblox.com/en-us/articles/Understanding-CFrame

CFrame Math Operations

https://developer.roblox.com/en-us/articles/CFrame-Math-Operations

By the way, it's funny that i answered on my own question.

This discussion is preserved as it was. New answers, comments, and votes are closed.