How can I change the angle of a part without changing its intersection point with another part?

Hello everyone, so this is what i’m trying to accomplish visually:

I basically want to change the angle of the red part, but without changing the cut-off location/intersection point with the white part as you see here. When I tried to find a solution to the problem, I would change the angle but that would also change the way that it cuts off the top part of the white part. As you see here, the white wall is perfectly cut. I need to accomplish this.

Thank you.

You have to rotate it around the intersection. To do that you shift the rotated parts cframe so that it has the same position as the intersection, then do your rotation, then shift it back. The shift that you do will be a translation in the space of the rotated part.

Can you give me a simple example of that in code? Thanks.

It depends which CFrame of the pivot point you already have. Do you have it relative to the rotated part (like an Attachment.CFrame) or relative to the world (like an Attachment.WorldCFrame)?

No, I don’t have any of those unfortunately. I only rotate the CFrame by CFrame.Angles() in script, I don’t have an attachment. Thanks.

You dont need an attachment specifically but you need to know the CFrame or at least the position of where you want to rotate around.

Oh, in that case it would be the top location of the white part shown in my diagram above.

Yeah but you need to have the actual value in any case where you want to do this kind of rotation.