I've been a bit stuck on how to cleanly script BackgroundTransparency without doing this.
1 | script.Parent.Frame.BackgroundTransparency = 0.1 |
2 | wait( 0.05 ) |
3 | script.Parent.Frame.BackgroundTransparency = 0.2 |
4 | -- And on and on, its stressful and unclean. |
How can you script it to where it makes it cleanly play through the Transparency Frames?
Thank you for you're time.
You can use tweens to smoothly animate properties and get the result you want.
01 | local TweenService = game:GetService( "TweenService" ) |
02 | local object = script.Parent.Frame |
03 |
04 | local TweenInfo = TweenInfo.new( 0.5 , Enum.EasingStyle.Linear, Enum.EasingDirection.Out) |
05 |
06 | local goals = { |
07 | BackgroundTransparency = 1 |
08 | } |
09 |
10 | local tween = TweenService:Create(object, TweenInfo, goals) |
11 |
12 | tween:Play() |
You can just use for loop, which will repeat script needed amount of time
Here's the code:
1 | for i = 1 , 9 do |
2 | wait( 0.05 ) |
3 | script.Parent.Frame.BackgroundTransparency = tonumber ( "0." ..i) -- convert 9 to 0.9 |
4 | end |
And that's just it!