Tween, Unable to cast to Dictionary

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I would like to be able to have a tween animation where the camera moves from a position to another.

  2. What is the issue? Include screenshots / videos if possible!
    This error comes out: Unable to cast to Dictionary

local FatherWinterModule = {}

function FatherWinterModule.FirstCamera(player)
	--Camera
	local currentcamera = workspace.CurrentCamera
	local pc = workspace.Winter.WinterCam
	local FinalPosition = workspace.Winter.FinalWinterCam
	currentcamera.CameraType = Enum.CameraType.Scriptable
	currentcamera.CFrame = pc.CFrame

	--Variables
	local TweenService = game:GetService("TweenService")
	local Father = workspace.Winter.FatherWinter

	local CameraMove = TweenService:Create(currentcamera.CFrame, TweenInfo.new(1), FinalPosition.CFrame)
	CameraMove:Play()
end

return FatherWinterModule
  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Tried looking around, found nothing

The argument where you put the CFrame actually needs to be a dictionary. Each key inside the dictionary is the property you want to change (written exactly as is in the properties tab) and the value is the value you want it to change to

{
    CFrame = FinalPosition.CFrame
}
2 Likes

It says : Unable to cast value to Object now

local CameraMove = TweenService:Create(currentcamera.CFrame, TweenInfo.new(1), {CFrame = FinalPosition.CFrame})
	

In your first argument you specify currentCamera.CFrame, giving the function the cameras CFrame. But this function expects an object as the first argument, so it tries to convert it to an object (which is not possible). Remove the .CFrame

local CameraMove = TweenService:Create(currentcamera, TweenInfo.new(1), {CFrame = FinalPosition.CFrame})

1 Like
local CameraMove = TweenService:Create(currentcamera, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = FinalPosition.CFrame})

I think you forgot EasingStyle and EasingDirection

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.