Error unable to cast to dictionary while tweening

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to use a variable to change the tweening distance for a gui
  2. What is the issue? Include screenshots / videos if possible!
    I get the error: unable to cast to dictionary
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Looked on the devforum, but no one actually ever answers my question
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

my code:

				local tween = tweenService:Create(game.Players.LocalPlayer.PlayerGui.ItemWeight.TextLabel, tweenInfo, {TextTransparency = 0})
				tween:Play()
				local e = {0.996*weight/3, 0}
				print()
				local tween = tweenService:Create(game.Players.LocalPlayer.PlayerGui.ItemWeight.Frame.Frame, tweenInfo, {Size = e,{0.72, 0}})

weight is a number value, even if I change it, nothing matters. The first tween works, but the second does not.

As far as I understand, the new value for the Size needs to be defined using the UDim2.new() constructor so that it’ll be referring to the desired end value for the size of that GuiObject. Right now, it’s referring to 2 tables, which is why the script is not able to create the Tween.

Here’s an example revision:

Example Revision

local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")

local player = Players.LocalPlayer
local PlayerGui = player:WaitForChild("PlayerGui")

local ItemWeight = PlayerGui:WaitForChild("ItemWeight")
local TextLabel = ItemWeight:WaitForChild("TextLabel")
local Frame1 = ItemWeight:WaitForChild("Frame")
local Frame2 = Frame1:WaitForChild("Frame")

local weight -- Value that is referenced later on when calculating the "e" variable
local tweenInfo -- Reference for the tweenInfo

local tween = TweenService:Create(TextLabel, tweenInfo, {TextTransparency = 0})
tween:Play()

local e = (0.996 * weight / 3)
local goal = UDim2.new(e, 0, 0.72, 0)
local tween2 = TweenService:Create(Frame2, tweenInfo, {Size = goal})
tween2:Play()