Make a CFrame with position and rotation

I need to know a way to make a CFrame with a position and a rotation

--It should be that
local pos = Vector3.new(1,23,4) --studs
local rot = Vector3.new(0,45,0) --degrees
CFrame.new(pos,rot)
--But it's not

I know that CFrames uses radians…
But here rot is taken as a LookAt thing! Mindblowing (means that LookAt thing is useless)
We can convert 2 Vector3 for position and rotation into a CFrame, but how?
(making the sum of CFrame.new(pos) and CFrame.Angles(rot) doesn’t work)

3 Likes

There’s not a method for creating CFrames with position and rotation in the way that you’ve described. The simplest way to achieve what you want is to construct a CFrame using your position vector, then multiply it by a CFrame.angles constructed of the x,y,z components of your rot vector.

local cf = CFrame.new(pos) * CFrame.Angles(rot.x, rot.y, rot.z)

(Remember to convert your rot xyz values to radians)

28 Likes

CFrames are confusing, to make the sum of two CFrames, it should be CF1 + CF2 but nope!
It’s CF1 * CF2!

19 Likes