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

How do I make the background of a gui flash in and out of transparency?

Asked by 6 years ago

I'm trying to make the background of the gui keep transitioning from being visible to being transparent, this is what I have thought of so far.

01BetaPassNeededGui = script.Parent
02Up = false
03BetaPassNeededGui.BackgroundTransparency = 0
04while true do
05    print("Script Active")
06    wait()
07    while Up == true do
08        print("Mode = ".. Up)
09        while BetaPassNeededGui.BackgroundTransparency <= 1 do
10            BetaPassNeededGui.BackgroundTransparency = BetaPassNeededGui.BackgroundTransparency + 0.1
11            wait(0.1)
12            if BetaPassNeededGui.BackgroundTransparency == 1 then
13                Up = false
14            end
15        end
View all 26 lines...
0
You are using quite a lot of while loops. Consider creating a function instead. Zafirua 1348 — 6y

1 answer

Log in to vote
1
Answered by
oreoollie 649 Moderation Voter
6 years ago
Edited 6 years ago

I think that tweening is a much cleaner way to achieve what you want. If you want to change how long it takes for the transparency to change, modify the ChangeTime variable.

01local ChangeTime = 1 -- Time in seconds
02 
03local twn
04local BGui = script.Parent
05local t = game:GetService("TweenService")
06 
07BGui.Transparency = 0
08 
09while BGui.Visible do
10    twn = t:Create(BGui, TweenInfo.new(ChangeTime, Enum.EasingStyle.Linear), {Transparency = 1}) twn:Play()
11    twn.Completed:Wait()
12    twn = t:Create(BGui, TweenInfo.new(ChangeTime, Enum.EasingStyle.Linear), {Transparency = 0}) twn:Play()
13    twn.Completed:Wait()
14    twn = nil
15    wait()
16end

If my answer helped you please make sure to mark it as correct!

Ad

Answer this question