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

How do I make a for loop that it increases the transparency of a GUI until it is invisible?

Asked by 5 years ago

I want to make a for loop that it increases the transparency of GUI until it is invisible. Can someone give me the code or explain to me how to do it?

2 answers

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

We start the for loop at 0 and make it go to 1 at a rate of .01 per wait()

1function run()
2    for i=0, 1, .01 do
3        ui.Transparency=i
4        wait()
5    end
6end
7button.MouseButton1Click:Connect(run)

Transparency is a number from 0 to 1 so we need to slowly increase the number to see a result, hence the .01

0
How can I make it so when I click a button on the gui it plays this script? AwesomeMrBird -79 — 5y
0
@AwesomeMrBird Edited answer DanzLua 2879 — 5y
Ad
Log in to vote
0
Answered by
Lazarix9 245 Moderation Voter
5 years ago

This is basically it just add some more stuff if you have more frames or textlabels or that stuff and the condition and yeah.

01local ScreenGUI = script.Parent
02local frame = ScreenGUI.Frame
03local TextLabel = frame.TextLabel
04 
05for i = 1, 10, 1 do
06 
07    frame.BackgroundTransparency = frame.BackgroundTransparency + 0.1
08    TextLabel.BackgroundTransparency = TextLabel.BackgroundTransparency + 0.1
09    TextLabel.TextTransparency = TextLabel.TextTransparency + 0.1
10    wait(0.1)
11 
12end

If you have any questions ask in the comments

0
How can I make it so when I click a button on the Gui it plays this script? AwesomeMrBird -79 — 5y
0
How can I make it so when I click a button on the gui it plays this script? AwesomeMrBird -79 — 5y

Answer this question