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

Lerp (Linear Interpolation) is not working. Can somebody help?

Asked by 8 years ago
1TextBox.Focused:connect(function()
2        for i = 0,1,0.01 do
3        print(i)
4        Frame.BackgroundColor3:lerp(colors[Color][800], i)
5        Frame.Size:lerp(UDim2.new(XSize,0,0,3),i)
6        wait(0.01)
7        end
8end)

you can probably predict what is going on here

2 answers

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

Something you should know: lerping ScreenGuis is gratuitous

Use TweenSize!

1TextBox.Focused:connect(function()
2    local targetSize = UDim2.new(XSize,0,0,3);
3    Frame:TweenSize(targetSize,"InOut","Linear",.2);
4    repeat wait() until Frame.Size == targetSize;
5end)
0
Sometimes this happens mightydifferent 85 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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;

01function 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
09end
10 
11function 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
View all 37 lines...

As for the Frame's size, simply use TweenSize;

1Frame.Size:TweenSize(UDim2.new(XSize),0,0,3), "Out", "Sine")

Answer this question