Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help with TweenSize

Asked by
Damo999 182
10 years ago

I'm not really sure how TweenSize works could someone please explain it to me thanks.

1 answer

Log in to vote
1
Answered by
coo1o 227 Moderation Voter
10 years ago

TweenSize is a method used on GuiObjects (That is, frames and TextButtons and all that) to smoothly change its size and make your game look quite clean. Ok so it takes 4 required arguments and 2 optional arguments. These arguments are as followed: UDim2 endSize, Enum easingDirection, Enum easingStyle, float time and the optional arguments are Boolean override and function callback.

Ok, so let's break these arguments down.

endSize is a UDim2 value and it indicates the size it will reach. So say I have a TextLabel in a ScreenGui, it's UDim2 size is (0.5,0,0.5,0) and I want to change it to (0.7,0,.4,0), that's what I'll put as the endSize for TweenSize.

easingDirection is an Enum value that indicates how easingStyle should run. You can write it as a string because your setting the Enum, not checking it. This Enum consists of three values; "Out", "In" and "InOut". "Out" applies the easingStyle normally, "In" applies easingStyle in reverse and "InOut" applies easingStyle in reverse then halfway it will apply normally.

easingStyle is also an Enum that indicates the transition. There are a few, my personal favorite being "Sine". Click here to see the list of easingStyles and remember that it can be written as a string because we are setting an Enum, not indexing it.

time is a float that just indicates how long the tweening will take, meaning that it controls both the time to reach its goal and its velocity.

Now that the required arguments are covered, lets move onto the optional ones

override is a boolean that indicates if the tweened GuiObject can be overridden, meaning if my TextLabel is being tweened, another tween can take over. If override is set to false then if you try to tween a GuiObject that's already being tweened (We are referring to this tween's override) then our new tween won't work and the first tween will just continue to reach it's goal. NOTE: If override is not included it will be by default false

callback is a function that will be called when the tween reaches its goal. Here's an example:

function Delete()
    TextLabel:Destroy() --Just pretend that TextLabel is already defined
    print('Deleted! :3')
end

TextLabel:TweenSize(UDim2.new(0.7,0,0.4,0), 'Out', 'Sine', 3, false, Delete())

I just made that right now but it should delete the (Actually undefined) TextLabel when it reaches its goal of (0.7,0,0.4,0) within the 3 seconds we gave it. 'Sine' is an easingStyle that starts off at normal velocity then gradually slows down. The easingDirection is "Out" so "Sine" will be applied normally and no other tween can takeover.

Thanks for reading my answer and if you did, thanks for accepting it and/or rating it. C: Also, if you want the wiki's guide, click here.

Ad

Answer this question