CFrame manipulation with rotation

I’m already pretty decent at scripting however CFrame manipulation specifically related to rotation has always bugged me, because for some reason you cant just edit a simplified property like Position:

I’m currently trying to combine a CFrame containing a position, with a CFrame containing simply a Y rotation to create a CFrame containing a position and rotation around the Y axis (like how a turret would function). I have both CFrames, however the problem is I dont know how to extract the Y orientation value from the rotated CFrame to then use to combine with the position CFrame? This is my current code where i tried using LookVector to get the rotation of the CFrame, however I dont actually know how to convert this unit vector into a normal orientation vector like you would see in the Property tab of an instance like a BasePart.

Here is my current code:


(keep in mind it doesnt actually work and this is why i posted this in scripting support)

here is a little drawing fully explaining the situation and problem: (the CFrames i already have are circled in magenta)

bumping as of right now however i will not be able to respond anymore today as i go to sleep; if you see this in the meantime please ask questions incase you are unsure of anything i have explained to at least give me something to reply to quickly once i return tomorrow

Have you tried using CFrame.lookAt()?

local Position = StartingPointAttachment.WorldPosition
local Direction = DirectionalForStart.Position
StartingPoint = CFrame.new(Position) * CFrame.Angles(0, CFrame.lookAt(Position, Direction).Rotation.Y, 0)

Hope this helps.

yes, the “directionalforstart” variable is my rotated on x,y,x cframe using cframe.lookat, but it sadly isnt as simple as you have shown in your code example;


even when you do .Rotation.Y, .Rotation gives me my only rotated cframe, but .Y doesnt actually give me the Y value to this rotation, it instead gives me the Y value of the position which will be 0 if .Rotation clears this

dw anyway, i found a workaround for this problem and dont really need the answer anymore other than just for CFrame manipulation wisdom lmao, also sorry for the very late reply

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.