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

How can you script BackgroundTransparency Cleanly?

Asked by 4 years ago

I've been a bit stuck on how to cleanly script BackgroundTransparency without doing this.

1script.Parent.Frame.BackgroundTransparency = 0.1
2wait(0.05)
3script.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.

2 answers

Log in to vote
1
Answered by 4 years ago

You can use tweens to smoothly animate properties and get the result you want.

01local TweenService = game:GetService("TweenService")
02local object = script.Parent.Frame
03 
04local TweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
05 
06local goals = {
07    BackgroundTransparency = 1
08}
09 
10local tween = TweenService:Create(object, TweenInfo, goals)
11 
12tween:Play()
0
I'll try it CodedStars 70 — 4y
0
ye, that's a good one, but long GravityGouse99938 75 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

You can just use for loop, which will repeat script needed amount of time

Here's the code:

1for i = 1,9 do
2    wait(0.05)
3    script.Parent.Frame.BackgroundTransparency = tonumber("0."..i) -- convert 9 to 0.9
4end

And that's just it!

Answer this question