Is this code wrong?

Hello!

I am working on a tween script and I’m changing the position of a frame when a button is hovered over.

Here’s the code:
btn.Parent.Shop:TweenPosition(UDim2.new(0.968,0,0.55,0), 0.2)

It does work, but doesn’t move within 0.2 seconds, or at least doesn’t seem like it. Am I doing something wrong?

Please refer to these parameters that can be found here

0.2 is passed at the easingDirection parameter. That is not correct

btn.Parent.Shop:TweenPosition(UDim2.new(0.968,0,0.55,0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 0.2)

Is the proper way to do it.

Also please do not use TweenPosition, it is deprecated.

Best,
Matthew

1 Like

Alright. Thanks so much for your help!

For future reference, using TweenService is the better alternative. Here’s an example:

local TweenService = game:GetService("TweenService")
local animation = TweenInfo.new(0.2)

TweenService:Create(btn.Parent.Shop, animation, {
     Position = UDim2.new(0.968,0,0.55,0)
}):Play()

I would appreciate if you marked this answer as the solution :pray:

Have a good day.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.