Unable to cast to Dictionary

What I am trying to achieve is that when I click on a button the perspective of the camera changes, but I get this error
image

Here is my script

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

local item = script.Parent.Parent:WaitForChild("CameraToSee")

local maximum = script.Parent.Parent.MaxCameras
local minimum = script.Parent.Parent.MinCameras
local RunService = game:GetService("RunService")

local TweenService = game:GetService("TweenService")
local Tween = TweenInfo.new(
	0,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.In,
	0
	
)



script.Parent.MouseButton1Click:Connect(function()
	if item.Value > minimum.Value then
		item.Value = item.Value - 1
		local CameraToViewGoal = game.Workspace.Cameras:WaitForChild("Camera"..item.Value)
		local CFrameOfCamera = CameraToViewGoal.CFrame
		
			local AnimationCamera = TweenService:Create(camera, Tween, CFrameOfCamera)
			camera.CameraType = Enum.CameraType.Scriptable
			AnimationCamera:Play()
		
		
	elseif item.Value == minimum.Value then
		item.Value = maximum.Value
		local CameraToViewGoal = game.Workspace.Cameras:WaitForChild("Camera"..item.Value)
		local CFrameOfCamera = CameraToViewGoal.CFrame
		
			local AnimationCamera = TweenService:Create(camera, Tween, CFrameOfCamera)
			camera.CameraType = Enum.CameraType.Scriptable
			AnimationCamera:Play()

		
	end
end)

Screenshots:
image

image

Tweening requires a table of properties as the goal. Wrap it in curly brackets to make it a table.

local CFrameOfCamera = {CFrame = CameraToViewGoal.CFrame}
1 Like