local ObjGui = script.Parent
local ObjFrame = ObjGui.ObjectiveFrame
local ObjText = ObjFrame.ObjectiveFrame.TextLabel
--
local ObjInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
local InPos = {Position = {-0.022, 0},{0.783, 0}}
local OutPos = {Position = {-0.4, 0},{0.783, 0}}
--
local TweenIn = TS:Create(ObjFrame, ObjInfo, InPos) -- Error Here
local TweenOut = TS:Create(ObjFrame, ObjInfo, OutPos)
The line where it says Error Here the output always says “Unable to cast Dictionary.”
I think it is because of the InPos/OutPos being like that format, but I do not know how to tween the position of Gui’s when the position is like that.
Gui objects have a method to tween their position: GuiObject:TweenPosition() which requires a Udim2 value. However if you want to use TweenService then that’s not how you tween a position. Positions are represented by Vector2 and Udim2; in this case since you are working with GUI objects you must use Udim2 as the position value for GUI objects is made out of scale and offset coordinates, in conclusion you will need to define the position value in the properties dictionary like this:
local propertiesToTween = {
Position = Udim2.new({ScaleX, OffsetX}, {ScaleY, OffsetY}))
}
It isn’t pretty yet, but this should be the fixed script:
local ObjGui = script.Parent
local ObjFrame = ObjGui.ObjectiveFrame
local ObjText = ObjFrame.ObjectiveFrame.TextLabel
local ObjInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0)
local InPos = -0.022
local OutPos = -0.4
local TweenIn = TS:Create(ObjFrame, ObjInfo, {Position = UDim2.new(InPos,0,0.783)})
local TweenOut = TS:Create(ObjFrame, ObjInfo, {Position = UDim2.new(OutPos,0,0.783)})
-- Make sure to also Play the tween