Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Unable to cast Dictionary to TweenInfo?

I was trying to make a repeating and tweening camera using while true do and tweeninfo. The current camera CFrame starts on the first camera and would switch into the second camera every 7 seconds with a tween and also on repeat.


local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

local tweenService = game:GetService("TweenService")

function tween(part1, part2)
	local tweenInfo = TweenInfo.new(5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
	local tween1 = tweenService:Create(camera, TweenInfo, {CFrame = part2.CFrame})
	local tween2 = tweenService:Create(camera, TweenInfo, {CFrame = part1.CFrame})
	while true do
		camera.CFrame = part1.CFrame
	
		tween1:Play()
	
		wait(7)
	
		tween2:Play()
		
		wait(7)
	end
end

tween(game.Workspace.Cam1, game.Workspace.Cam2)

1 comment

0

oh wait i realized, you made a typo in line 8 and line 9

1 answer

✓ Accepted answer

In the Create functions, you meant to type tweenInfo instead of TweenInfo for the 2nd argument. It references the TweenInfo dictionary instead of your TweenInfo instance

This discussion is preserved as it was. New answers, comments, and votes are closed.