How do you rotate a CFrame on the global axis?

You can only do one parameter at a time though.

Sorry to bump this thread but I’ve seen a few people come looking for a solution to this issue and I’m sure people would like to have a working solution here:

--Change this to the part you're rotating
local Part = workspace.WhateverYourPartIs
local CF = Part.CFrame
--Doesn't have to be stored like this but it helps for clarification
--Change this to the actual angles you're rotating by
local Angles = CFrame.Angles(0,math.pi/2,0)
--Gets the new CFrame in relation to the rotated world Axes
local RotCF = Angles:ToObjectSpace(CF)
--Easier to use fromMatrix here, because it's faster and allows us to use
--the rotational component of the RotCF while preserving position
Part.CFrame = CFrame.fromMatrix(CF.Position,RotCF.XVector,RotCF.YVector,RotCF.ZVector)

Anyways, I hope this works as a solution!

25 Likes

Press Ctrl + L to switch from local to global.

actually read the post before replying bruh

3 Likes

here’s a more intuitive solution I ended up using for the same problem

local cf = part.CFrame
local pos = cf.Position
cf = cf - pos -- get rid of position
cf = CFrame.Angles(0, math.rad(1), 0)) * cf -- rotate the cframe around globally
cf = cf + pos -- add the position back
part.CFrame = cf

simplifiable into this one liner

part.CFrame = (CFrame.Angles(0, math.rad(1), 0) * (part.CFrame - part.Position)) + part.Position
1 Like

This post is a year+ old… I’m sure they’re fine. Just thought I’d point that out.

This devforum thread is the top google search result for this exact question. It is very important for it to be answered.

1 Like

Fair enough.

iuwefghiuwerfwefgwe

This question is addressed in the first opening paragraphs of this Community Tutorial: