Output keeps saying "Unable to cast to Dictionary" whenever I try creating a local tween

I’ve been trying to look for ways to fix the issue but I couldn’t find anything that on the devforum to help me out.

My goal was to create a TV that flashes different colors every 5 seconds

This is the line of code that keeps getting the error:

local tween1 = TweenService:Create(Tv,tweeningInformation,screen1)

This is the error:
Unable-to-cast-to-dictionary

This is the model my script is in
Model-Image

And, this is the whole script:

-- Created by GalacticQuasar, July 18, 2020 ("TV Screen Flashing Different Colors")

-- Variables
local TweenService = game:GetService("TweenService")
local Tv = script.Parent:WaitForChild("Screen")

-- Main:
local tweeningInformation = TweenInfo.new(
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

-- All Colors Goals & Tweens
local screen1 = {Color3.new(17, 17, 17)}
local screen2 = {Color3.new(112,0,1)}
local screen3 = {Color3.new(0, 22, 66)}
local screen4 = {Color3.new(36, 34, 80)}
local tween1 = TweenService:Create(Tv,tweeningInformation,screen1)
local tween2 = TweenService:Create(Tv,tweeningInformation,screen2)
local tween3 = TweenService:Create(Tv,tweeningInformation,screen3)
local tween4 = TweenService:Create(Tv,tweeningInformation,screen4)

-- Tweening Scripts
Loop = true
while Loop == true do
tween1:Play()
wait(5)
tween2:Play()
wait(5)
tween3:Play()
wait(5)
tween4:Play()
wait(5)
end

Thank you to everyone who can help me out with this! I appreciate it!

When creating a Tween, you can’t just slap in a value and expect TweenService to know how to use it. You have to set your value, to your objects property you want to affect. The TweenService requires a dictionary, not a table.

For example:

local tween1 = TweenService:Create(Tv,tweeningInformation,{Color = Color3.new(17, 17, 17)})

All you have to do, is add “Color =”, before your Color3 value, so that your program knows what to apply the color to.

1 Like

You see the proprieties table of a Tween:Create function is a dictionary, meaning you’ll have to make the table’s keys to what you want to tween. So you’d have to change your screens to

{Color = Color3.new(--[[YOUR VALUES HERE]])}
1 Like

Oh, I see. Sorry, I keep forgetting to add color before color3 in my scripting. Thanks!

1 Like

Oh, I see. Thanks for the help too!