How would I change the CFrame of this part so that this attachment is in the place of another part

How would I change the CFrame of this so that this attachment is in the place of another part
image

idk if i explained this very well

Maybe, you should explain more and also show what you tried and what went wrong.

i’ve tried nothing cus i couldn’t come up with anything

im trying to change this part’s cframe so that the cframe of the attachment inside of it corresponds to the second parts cframe (the semitransparent one)

The attachment has the same position of the part so you could just subtract the difference in position between current and goal, then add that difference to current to move it to goal.

Ok I think that explanation is better.

Are you expecting something like this?

Script
--Attachment WorldCFrame formula
--attachmentWorldCFrame = part.CFrame * attachment.CFrame

local part = script.Parent
local attachment = part.Attachment

local part2 = workspace.P2

part.CFrame = part2.CFrame * attachment.CFrame:Inverse()

Before:

After:

1 Like

if you use a RigidConstraint

then you can have a attachment in each part and the RigidConstraint will keep the 2 attachments perfectly aligned

1 Like

yes, that is what i am looking for