Attempt to modify readonly table

this error says, Attempt to modify readonly table. how do i fix it.

	CFrame.new = root.CFrame * CFrame.Angles(node.RotationValue.Value.X,node.RotationValue.Value.Y,node.RotationValue.Value.Z)	

1 Like

You probably meant somePart.CFrame = not CFrame.new =

You don’t set CFrame.new equal to something lol

yeah now it looks weird, how do i make so it stays the rotation.
RobloxScreenShot20221218_185556112
AND not teleport to the waypoint

You only want it to rotate? Just remove the position from the CFrame so it’s only rotate

this is the line

	root.CFrame = CFrame.Angles(node.RotationValue.Value.X,node.RotationValue.Value.Y,node.RotationValue.Value.Z)	

A good way is through:

CFrame:ToOrientation()

MyCFrame = CFrame.Angles(node.RotationValue.Value.X,node.RotationValue.Value.Y,node.RotationValue.Value.Z)
MyCFrame = MyCFrame:ToOrientation() 
root.CFrame = MyCFrame 

doesn’t even work for the both of the replies you made :confused:

:ToOrientation() doesn’t work? You’ll have to do some research on that one : p

1 Like

wait, i can show you a script

MyCFrame = CFrame.Angles(node.RotationValue.Value.X,node.RotationValue.Value.Y,node.RotationValue.Value.Z)
	MyCFrame2 = MyCFrame:ToOrientation() 
	root.CFrame = MyCFrame2

made some edits, thought it was gonna fix it.

1 Like

Not sure if I’m understanding this post correctly, but can’t you just do this to rotate the CFrame whilst keeping everything else? It worked for me numerous times I’ve used it:

root.CFrame = root.CFrame * CFrame.Angles(math.rad(node.RotationValue.Value.X), math.rad(node.RotationValue.Value.Y), math.rad(node.RotationValue.Value.Z))

I’m on my phone right now, so sorry if this doesn’t work right off the bat.

ToOrientation returns a number, so your code will indeed cause that error.

1 Like

it does, but how do you make so it doesn’t like overlap, because it goes the opposite direction if it uses the rotationvalue 2 times.

1 Like

Oh yea you’re right, sorry bout that, honestly haven’t used CFrame in a while, is this closer to what would work? :

MyCFrame = CFrame.Angles(node.RotationValue.Value.X,node.RotationValue.Value.Y,node.RotationValue.Value.Z)
local x, y, z = MyCFrame:ToOrientation()
local CFrameToUse = CFrame.Angles(math.rad(x),math.rad(y),math.rad(z)) 

I think this is what you’re looking for.

root.CFrame = CFrame.new(root.Position) * CFrame.Angles(math.rad(node.RotationValue.Value.X), math.rad(node.RotationValue.Value.Y), math.rad(node.RotationValue.Value.Z))

That would work, but the second line undoes the first line, and the third line redoes it.

Does this get rid of the position value in the CFrame?

1 Like

Based on what he said here

I assumed he wanted to combine root's position and node's rotation, and this does that.

1 Like