Connect 2 attachments?

Hi. This question has already been asked but the creator of the thread ended up using an entirely different method, in which I cannot do.

Basically, I want 2 attachments to connect.

I have a script that when the 2 attachments are in proximity, it will hopefully make the attachments connect. But, it won’t work. Given that the two parts are oriented like this, how would I make them basically connect with eachother?

animation-modulematching-600px

Hey there again, the reason why the previous solution didn’t work is that welds is dependent on CFrames so it might cause overlapping if the attachments orientations are specific.

Probably overcomplicated it previously.

To neglect rotation just calculate the displacement between the two attachments.

local part0 = workspace.Part0
local part1 = workspace.Part1

local displacement = (part0.Attachment0.WorldPosition-part1.Attachment1.WorldPosition)
part1.CFrame += displacement
4 Likes

I tried doing this with models and it didn’t work. Did I do something wrong here? I swear my math is right

local part0 = workspace.BoundingBox2
local part1 = workspace.BoundingBox1

local displacement = (part0.Box.Attachment0.WorldPosition-part1.Box.Attachment1.WorldPosition)

part1:SetPrimaryPartCFrame(part1.PrimaryPart.CFrame * CFrame.new(displacement))

4b550034f6975646cc59f0c84791d3ec

they just end up inside eachother

Do not use CFrame multiplication.

This makes the displacement relative to the local primary part orientation XYZ Axis.

part1:SetPrimaryPartCFrame(part1.PrimaryPart.CFrame +(displacement))

Otherwise you can still use CFrame multiplication, but order heavily matters:

part1:SetPrimaryPartCFrame(CFrame.new(displacement)*part1.PrimaryPart.CFrame )
3 Likes