Unable to cast value to object

I have a script that makes camera movement smooth and adds the ability to switch between a third person and first person perspective using a toggle keybind, it uses cframe values to change the camera offset but I want to instead for them to be tweened, but I ran into a error: “Unable to cast value to object” I am not sure why. Here is the portion of the code that I am talking about:

local function ChangeCamera(input)
	if input.KeyCode == Enum.KeyCode.Q then
		if CAMERA_MODE then
			--CAMERA_OFFSET = CFrame.new(3,-0.8,7)
			TweenService:Create(CAMERA_OFFSET,TweenInfo.new(1),{CAMERA_OFFSET = CFrame.new(3,-0.8,7)}):Play()
			CAMERA_MODE = false
			--CAMERA_OFFSET = CFrame.new(0,1,-0.5)
			TweenService:Create(CAMERA_OFFSET,TweenInfo.new(1),{CAMERA_OFFSET = CFrame.new(0,1,-0.5)}):Play()
			CAMERA_MODE = true

I honestly have no idea how to tween cframe values so this is really throwing me for a loop.

1 Like

What is CAMERA_OFFSET referencing?

Just a Cframe value:

local CAMERA_OFFSET = CFrame.new(3,-0.8,7)

I found a solution by creating a CFrameValue object instead and just tweening the value of that since I was not tweening an object previously.