Unable to cast to Dictionary when tweening TextColor3

Hi!
I want to tween a TextButton’s TextColor3 when the mouse is hovering over it but I’m having a bit of trouble.

This is the error:

This is the localscript inside the TextButton:

local TS = game:GetService("TweenService")

local btn = script.Parent

local isHovering = false

btn.MouseEnter:Connect(function()
	isHovering = true
	
	local tweenInfo = TweenInfo.new(.5)
	
	local goal = {TextColor3 = Color3.new(0.745098, 0.745098, 0.745098)}
	
	local tween = TS:Create(btn, TweenInfo, goal)
	tween:Play()
end)

Does anyone know why it’s not working?

Did you do a typo by any chance? I think you meant to do this

local tween = TS:Create(btn, tweenInfo, goal)

You were not referencing the variable you had for the tween info, you were referencing the TweenInfo constructor

1 Like

It seems as though you have case-sensitive variables, this should fix it

local TS = game:GetService("TweenService")

local btn = script.Parent

local isHovering = false

btn.MouseEnter:Connect(function()
	isHovering = true
	
	local tweenInfo = TweenInfo.new(.5)
	
	local goal = {TextColor3 = Color3.new(0.745098, 0.745098, 0.745098)}
	
	local tween = TS:Create(btn, tweenInfo, goal)
	tween:Play()
end)

You’re attempting to create a new TweenInfo since it’s a constructor, but you instead have to reference it as your variable tweenInfo

1 Like

My apologies, the error seemed to refer to goal, and not to tweenInfo so I never bothered to check for typos at all. Yeah, that was the issue. Thanks for pointing it out!

1 Like

Thanks for replying! You were both right, the problem was that I didn’t check for typos.