How to edit CFrame position?

Hi, I have problem, that i need to edit position of existing CFrame, I tried this


but it gives this error: 10:31:54.985 - p cannot be assigned to


Roblox’s CFrame datatype is immutable, meaning it cannot be changed.

What is cf defined as? Maybe I can help more if I see what you’re doing this for.

I have existing cframe, and i need cframe with same rotation, but diferent position

1 Like

I am asking for where the cf variable is declared.

You need to make a new CFrame and set that as the CFrame of the thing you’d like to move.


its just cframe from part…

If this is from a part, simply set the Position from the part to the new position:

part.Position = servo.Attachment0.Position

ok, but i dont want to move the part, i need it for counting some angles, … for aiming canons

You have me confused, you told us earlier that you’d only like to change the position.

1 Like

ya, but not to chnge real parts position, but just change the position in var


local position = cf.Position

You could do that to point to the position, but I seriously don’t get you.

ok, but i need cframe, because then i use pointToWordSpace with it (and that is only reason why i need it)

You can also use a CFrame at this point but I think that you are using it uncorrectly.
Maybe you should try this:

part.CFrame =

also if you’d like to change only variable you should declare it as:

local newposition =

then you will have a value of Attachment0’s position in variable ‘newposition’.
I hope this helps. :herb:

1 Like

ok, but i need to have there orientation of the part

Insteas of moving it to the part, get the coordinates of the part and use Vector3 to move it.

1 Like

I have mathematic operation, in that i need cframe with orientation of some part and position of the atachment

Then you should use CFrame.Angles and change the X ,Y, Z variables.
Here is an simple code to use it.

local variable = * CFrame.Angles(

You can of course change the operator because I don’t know what posititon you are trying to get.
I hope this helps. :herb:


A simpler method would be to negate the current Position and add the attachment’s Position:

local var = (part.CFrame - part.Position) + servo.Attachment0.Position

Here’s a way to only set the Z-axis of a cframe, maintaining the current rotation:

local cframe =, part.CFrame.Position.Y, 0)) 
* part.CFrame.Rotation
1 Like