I'm working on something that involves two bricks. If one of the bricks rotate, then the other brick needs to stay the same distance away but rotate around it at the same time. Is there any way to script that?
✓ ANSWER ACCEPTED
Brick rotation help?
1 answer
✓ Accepted answer
If you want to preserve the relative orientation of another part to one that is rotating, then take two parts a and b; a is rotating. Get the new CFrame for a:
local new=a.CFrame*CFrame.Angles(0,math.pi/8,0)
set b's new CFrame relative to the change in a's CFrame:
b.CFrame=new*a.CFrame:inverse()*b.CFrame
set a's CFrame
a.CFrame=new
2 comments
0
Thank you, I appreciate it very much.
0
Alternatively, local relative = a.CFrame:toObjectSpace(b) a.CFrame = a.CFrame*CFrame.Angles(0, math.pi/8, 0) b.CFrame = a.CFrame:toWorldSpace(relative)
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
Could you please expand apon what you mean? I'm not sure what you mean.
Do you mean welding one brick to another? Or do you mean an Earth - Moon orbit where bot parts are individually moving?
I'll elaborate. There's two bricks. The side brick needs to maintain it's distance and rotation while remaining straight in accordance to the rotation of the first brick. For example, if the brick was 2 studs away from the right side, I want it to maintain that distance and straight rotation when the first brick gets rotated.
So you don't want the side brick to face in the same direction as the main brick?
No, I want it to have the same rotation as the main brick, but maintain the two stud ratio no matter what the rotation of the first brick is.
The answer is welding. I don't have access to studio now, but I may have access in a couple of hours, so if you could wait that long?
I know how to weld, but this needs to be a scripting thing. Welding would absolutely be detrimental to what i'm doing with it.
Oh, damn. I can't do it then :/