CFrame Construction Help for a Mesh Part Rotation

I have a script that can generates meshes (randomly, either an ‘s-bend’, a straight tube or a quarter torus) and then fits them together, by placing the CFrame of the new piece as the same as the old piece and correcting by an offset depending on the type of new piece. In essence, it makes a long, randomly shaped, connected tube.

I’m wanting to add rotation to the individual sections so the pieces will be at different orientations, however I still want the ends of the new piece and end piece to connect.

The furthest I’ve got is rotating along the y-axis (CFrame.Angles(0, Angle, 0)) however that obviously rotates around the centre of the mesh, rather than rotating around the start point of that tube piece (to maintain the connected-ness of the tube)

To start with I’m just trying to see if I can get the quarter-torus piece to rotate and offset successfully, and the size of that piece is (126.1,50,129.2) if it helps.

Just struggling to get the correct CFrame construction.


Tube pieces connecting together.


Rotating around centre of tube piece, rather than rotating around the start of tube piece.

Many thanks for the help!