How would I change a cframe's position while keeping its orientation?

I’m not sure how to do this. Multiplying the cframe by Vector3.new(0, 0, 0) and then adding the desired position doesn’t work. For some reason multiplying the position by 0 didn’t change it.

Just fill up the first 3 arguments.
CFrame.new(10,10,10)

Once you have that how do you set that cframe’s orientation to a part’s orientation without setting the cframe’s position to the part’s position as well?

Here you go.

local PosCFrame = CFrame.new(0,0,0)
local RotCFrame = part.CFrame
local CombinedCframe = CFrame.new(PosCFrame.X, PosCFrame.Y, PosCFrame.Z, select(4, RotCFrame:components())
6 Likes
local model = workspace.Model

model:SetPrimaryPartCFrame(model:GetPrimaryPartCFrame() * CFrame.Angles(0,math.rad(90),0)) -- cf.angles uses radians, so use math.rad to convert into degrees

Keep in mind that SetPrimaryPartCFrame and GetPrimaryPartCFrame will be deprecated in the future.

1 Like

From what I understand, you want to make two parts have a same orientation while having different positions.

Just do

local rotationComponentA = partA.CFrame - partA.Position
partB.CFrame = rotationComponentA + newPosition

or

partB.CFrame = partA.CFrame
partB.Position = newPosition -- this doesn't disrupt the rotation component

What, why?

1 Like

It will be deprecated for pivots. My bad, I think GetPrimaryPartCFrame will stay.

1 Like