Sandessat
(Sandy)
December 13, 2019, 6:34am
#1
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
DevConX
(DevConX)
December 13, 2019, 6:35am
#2
Please send a picture of the error message.
1 Like
Jaycbee05
(Jaycbee)
December 13, 2019, 6:37am
#4
You are giving a dictionary/table as your first parameter of your tweenService:Create
, instead of an instance (gui)
3 Likes
Sandessat
(Sandy)
December 13, 2019, 6:38am
#5
That’s what I’m trying to do…
1 Like
Sandessat
(Sandy)
December 13, 2019, 6:38am
#7
But, how can I make it to be in only 1 variable?
1 Like
Jaycbee05
(Jaycbee)
December 13, 2019, 6:40am
#8
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
Sandessat
(Sandy)
December 13, 2019, 6:43am
#9
Okay, let me see if that code works…
1 Like
Sandessat
(Sandy)
December 13, 2019, 6:45am
#10
Still sending me the error…
2 Likes
Sandessat
(Sandy)
December 13, 2019, 6:49am
#13
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