Remove reference to camera's CFrame

I want it so that even after the CameraType is set to Scriptable it will maintain the old Camera’s CFrame, but oldCFrame is acting as a reference to the Camera’s CFrame, meaning that if I update the camera’s CFrame, the variable changes. I want the old CFrame, not a reference to whatever the CFrame currently is.

Should be simple, but I don’t want to use hacky methods like: grabbing the old CFrame’s rotation / position and creating a new CFrame from this?

Current code:

local oldCFrame = camera.CFrame
camera.CameraType = “Scriptable”
camera.CFrame = oldCFrame --This is not the old CFrame, this is just the current CFrame because oldCFrame is a reference to the camera’s CFrame.

Edit: Solved, wasn’t the CFrame’s fault but rather a mistake on my end. incapaxx is correct, CFrame’s are never references, which is why I was confused.

1 Like

CFrames are immutable, meaning once created an attribute of it cannot change.

If this is somehow happening, make a copy of it

local oldCFrame = CFrame.new(camera.CFrame:GetComponents())
3 Likes