Camera tweening problems!

Hi! I am trying to learn camera manipulation and I do not know why this script doesn’t work

Script:

local ts = game:GetService("TweenService")
local cam = game.Workspace.Camera
local ctime = 10

local tinfo = TweenInfo.new(
	ctime,
	Enum.EasingStyle.Sine,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

function tween (part1, part2)
	cam.CameraType = cam.CameraType.Scriptable
	cam.CFrame = part1.CFrame
	
	local tween = ts:Create(cam, tinfo, (CFrame = part2.CFrame))
	tween:Play()
	
	wait(ctime)
	
	cam.CameraType = cam.CameraType.Custom
end

tween(game.Workspace.Test1, game.Workspace.Test2)

Error:

Players.TD0mitru.PlayerGui.LocalScript:18: Expected ')' (to close '(' at column 38), got '='; did you mean to use '{' when defining a table?

Thanks for reading!

you have to change this to
local tween = ts:Create(cam, tinfo, {CFrame = part2.CFrame})

(you gotta change ( to { since the property to tween should be inside a table)

1 Like

Yes , but why? this makes no sense for me

you put the property to tween inside of ( but it should be enclosed in curly brackers {

The 3rd argument for Create expects a dictionary

--Table
{52346, 23526, 235}

--Dictionary
{key = 5235, steve = "Aaaaa"}

They always use {}, () are more typically used for maths

print(5 + 3 / 2) --prints 6.5
print((5 + 3) / 2) --prints 4
1 Like

I might be wrong but I think this is how roblox formats the function Create.
Imagining Tween Service as a class and Create as its method here -

function TweenService:Create(object,info,goals)
for key,value in pairs(goals) do
object[key] = value
end
end

That parameter goals, expects a dictionary from which it sets the key of the object to the provided value.
again there is no possible way for me to know how they format this but from a basic understanding this can be done.