How to calculate CFrame with object as reference point

so I’m trying to get a cframe based on a part’s orientation. an example would be: part A has an orientation of 45, 0, 0 and the wanted result would be to rotate part A on it’s Y axis depending on the X axis (kind of like rotating diagonally)

how would i do that?

also, for the record it shouldn’t be a continuous rotation but rather taking a rotation input and rotating to that value instead of using it as an increment

The CFrame.Angles constructor sounds like what you want.
CFrames | Documentation - Roblox Creator Hub

-- Your part
local part = workspace.Part
-- Rotation angle for local Y
local rotationAngle = math.rad(30)
-- Create the new cf from the original and the new rotation angle(s)
local newCFrame = part.CFrame * CFrame.Angles(0, rotationAngle, 0)
-- Apply to part
part.CFrame = newCFrame

the issue I have is that my script runs in a loop and it basically has to, which results in constant addition and therefore constant rotation

this is what I’ve created:

local new_cframe = character.HumanoidRootPart.CFrame * CFrame.Angles(grav_X, rotation.Y, grav_Z)

So, you want the new cframe code to execute inside the loop but not continuously? A couple of quick fixes come to mind.

One option would be to set the rotation angle to 0 once you apply it. It will keep calculating and assigning new cframes but wont change the rotation. When you need to rotate, you’d set the rotation value to what you need and then reset it to zero after you create the cframe.

Another option would be to set a flag so that the cframe is only created and assigned when you set the flag to true. You’d then set it to false after you apply the cframe.

-- set applyRotation to true somewhere when the rotation needs to change
if applyRotation == true then
    local new_cframe = character.HumanoidRootPart.CFrame * CFrame.Angles(grav_X, rotation.Y, grav_Z)
    applyRotation = false
end