1 | TextBox.Focused:connect( function () |
2 | for i = 0 , 1 , 0.01 do |
3 | print (i) |
4 | Frame.BackgroundColor 3 :lerp(colors [ Color ] [ 800 ] , i) |
5 | Frame.Size:lerp(UDim 2. new(XSize, 0 , 0 , 3 ),i) |
6 | wait( 0.01 ) |
7 | end |
8 | end ) |
you can probably predict what is going on here
Something you should know: lerping ScreenGuis is gratuitous
Use TweenSize!
1 | TextBox.Focused:connect( function () |
2 | local targetSize = UDim 2. new(XSize, 0 , 0 , 3 ); |
3 | Frame:TweenSize(targetSize, "InOut" , "Linear" ,. 2 ); |
4 | repeat wait() until Frame.Size = = targetSize; |
5 | end ) |
When using lerp, I like to make functions so it's easier to do.
I made a simple function that goes through a table and lerps to whatever color is next;
01 | function hb(num) --This function is just a Hearbeat:wait(); it makes the lerp smooth |
02 | if num = = 0 or num = = nil then |
03 | game:GetService( "RunService" ).Heartbeat:wait() |
04 | else |
05 | for i = 0 ,num do |
06 | game:GetService( "RunService" ).Heartbeat:wait() |
07 | end |
08 | end |
09 | end |
10 |
11 | function llerp(gui,Table,timeToNextFrame,alpha,hbWait) |
12 | spawn( function () --This is so you can run other code while the llerp function is being ran |
13 | local Frame = 1 --Starting at table[1] |
14 | for t = 1 ,#Table, 1 do --Looping through the table |
15 | print ( "TABLE: " ..t) --This will print where the function is in the table |
As for the Frame's size, simply use TweenSize
;
1 | Frame.Size:TweenSize(UDim 2. new(XSize), 0 , 0 , 3 ), "Out" , "Sine" ) |