TweenPosition - Unable to cast TweenInfo to token

Currently trying to fix a TweenPosition which is stopping my script from functioning, throwing up the error in the title.

(Abridged version containing just the info and planned TweenPosition)

-- Variables
local BaseTalkLocation = UDim2.new(.5, 0, 0.575, 0)
local choiceTweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.In)

-- The Plan
DialogBox:TweenPosition(BaseTalkLocation, choiceTweenInfo)

Is there something misplaced or missing?

Pretty sure easing direction goes before easing style. Swap those two around and see if it works.

https://developer.roblox.com/en-us/api-reference/function/GuiObject/TweenPosition

if you look at the api you can see that TweenInfo isn’t used

-- Variables
local BaseTalkLocation = UDim2.new(0.5, 0, 0.575, 0)

-- The Plan
DialogBox:TweenPosition(BaseTalkLocation, Enum.EasingDirection.In, Enum.EasingStyle.Sine, 0.5)

how does this work?

1 Like

Tried that, but Output states that it expects the Style before Direction.

Yeah that’s probably because @D0RYU has the correct answer here. Technically you shouldn’t be using TweenInfo for this because the TweenPosition() function requires the first part of that second parameter to be an EasingDirection, however your first part of the TweenInfo is a number, so try not using TweenInfo, and doing everything D0RYU said because he explains it better than I do. I’m basically just reiterating what he already said.

Okay! Tried it and it works! I think I can root out the later errors for now.

In the meantime, I’ll try and see if I can find a way to condense the Direction and Style into a usable Variable without using TweenInfo. Perhaps with {} as a table?

-- Variables
local BaseTalkLocation = UDim2.new(0.5, 0, 0.575, 0)
local ChoiceTweenInfo = {
    Enum.EasingDirection.In,
    Enum.EasingStyle.Sine,
    0.5
}

-- The Plan
DialogBox:TweenPosition(BaseTalkLocation, table.unpack(ChoiceTweenInfo))

try this

You should look though TweenService:Create, it’s more customizable than TweenPosition and TweenSize.

Read about it here.

-- Variables
local ChoiceTweenInfo = {
    UDim2.new(0.5, 0, 0.575, 0),
    Enum.EasingDirection.In,
    Enum.EasingStyle.Sine,
    0.5
}

-- The Plan
DialogBox:TweenPosition(table.unpack(ChoiceTweenInfo))

if you want the position inside the table you can do this

1 Like