What's the Tweening Difference?

I was doing a work around earlier today for MouseEnter and MouseLeave functions, however, it didn’t solve the problem I was experiencing with the tweening of the icons. When leaving the button the color of the text would revert back to white, but the icon size would stay enlarged even though it was set to tween back to its regular size. And sometimes when entering a button it wouldn’t even tween at all.

I did however solve this problem. Instead of using…

guiObject:TweenSize(UDim2.new(1, 0, 1, 0), "Out", "Sine", 0.075)

I used the actual tweening service…

local tweenOut = game:GetService("TweenService"):Create(
    guiObject,
    TweenInfo.new(0.075, Enum.EasingStyle.Sine, Enum.EasingDirection.Out),
    {
        Size = UDim2.new(1, 0, 1, 0)
    }
)

-- skip to when used --

guiObject.InputChanged:Connect(function(inputObject)
    if inputObject.UserInputType == Enum.UserInputType.MouseMovement then
        if inputObject.UserInputState == Enum.UserInputState.Begin then
            tweenOut:Play()
        elseif inputObject.UserInputState == Enum.UserInputState.End then
            -- play another tweening property that changes the size back to (0.725, 0, 0.725, 0)
        end
    end
end)

Why does using the actual TweenService method produce amazing results as opposed to the normal :TweenSize method? Remember, with TweenSize the tweening was buggy, but with the TweenService method, it worked every time and never glitched out. Always scaled to the proper size based on guiObject input type no matter how fast the mouse moved into and out of a guiObject.

Thanks

In the :TweenSize() method, there’s a flag for overriding any other tweens that are currently playing. This flag defaults to false, meaning that the tween will not play if the object is still changing in size. You can fix this by adding a true after 0.075 as an argument.

Also, use Enums rather than strings for the EasingDirection and Easing Style :slight_smile:

2 Likes

Wow, thanks. I’ve been developing on ROBLOX for nearly 7 years, you’d think I’d know that lol