Receiving "Unable to cast to Dictionary" error for tween

Hello, why I’m receiving this error:
Unable to cast to Dictionary

I’m just trying to create a tween in only 1 variable with much parts that are going to be affected…

local bBTable = {
	mainScreen.aboutMeButton.buttonBackground,
	mainScreen.contactMeButton.buttonBackground,
	mainScreen.helpButton.buttonBackground,
	mainScreen.manageAccountButton.buttonBackground
}
local bBGoal = {
	ImageTransparency = 0
}
local buttonsFrameInfo = TweenInfo.new(
	2,
	Enum.EasingStyle.Quad,
	Enum.EasingDirection.InOut,
	0,
	false,
	0
)
local bBTween = tweenService:Create(bBTable, bBGoal, buttonsFrameInfo)

bBTween:Play()

Please help me!

15 Likes

Please send a picture of the error message.

1 Like

image

1 Like

You are giving a dictionary/table as your first parameter of your tweenService:Create , instead of an instance (gui)

3 Likes

That’s what I’m trying to do…

1 Like

But, how can I make it to be in only 1 variable?

1 Like

you cant give a table as your first parameter, try wrapping it in a loop instead:

for i,Gui in pairs( bBTable ) do

if Gui then
 local bBTween = tweenService:Create(Gui, bBGoal, buttonsFrameInfo)

bBTween:Play()

   end

end

This resource should help you with what TweenService:Create parameters require :TweenService | Documentation - Roblox Creator Hub

3 Likes

Okay, let me see if that code works…

1 Like

Still sending me the error…

2 Likes

Ignore this topic, I will just take a rest, thank you all guys!

2 Likes

To answer the initial question: the arguments you provided the Create function are wrong. It works like this:
TweenService:Create(Part, TweenInfo, Goal)

If you’re going to put the goal value inside the table, I’d do this:

local bBGoal = {
    ['ImageTransparency'] = 0
}

OR

local bBGoal = {}
bBGoal.ImageTransparency = 0

To get all the button backgrounds to follow suit, use a for loop, like so:

for _, buttonBackground in ipairs(bBTable) do
    local bBTween = tweenService:Create(buttonBackground, buttonsFrameInfo, bBGoal)
    bBTween:Play()
end
42 Likes