How to edit welded part's CFrame without editing it's welded counterpart's CFrame

Imagine I have Part A and Part B. I want to have part B welded to part A, so that when I move part A’s CFrame, part B will move alongside it. In addition, I want part B to be constantly facing the user’s camera.

I have this functional and working, but since part B is always facing the user’s camera, it is rotating part A’s CFrame, which is something that I do not want. I wish part A to move part B, but B shouldn’t move A.

Currently, I have the following structure.

Model
– Body
----WeldConstraint(Part0: Body, Part1: Button)
– Button

In a separate script, I am moving the body (in reality a root part that moves the body via weldConstraint). The code that moves the button (part B) to always face the user’s camera is

part.CFrame = CFrame.new(part.Position, camera.CFrame.Position)

How can I reach the same results, having part B face the user / being able to edit it’s CFrame, without changing part A’s?

Alright, I’ve got a solution. It might not be the most efficient one, but here is how it works.

For every button that I have (I am using tags), I create a new instance called “anglelBlock”. I then assign the CFrame position to the angleblock, and then change the part’s orientation to the angleblock’s orientation.

			angleBlock.CFrame = part.CFrame
			angleBlock.CFrame = CFrame.new(part.Position, camera.CFrame.Position)
			part.Orientation = angleBlock.Orientation

The reason for doing this is because if I just created the CFrame object, there was no way for me to get the orientation value. This may be not be the most efficient, but it works! If anyone else has a better idea I’d love to hear it.

2 Likes