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()

function run()
    for i=0, 1, .01 do
        ui.Transparency=i
        wait()
    end
end
button.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.

local ScreenGUI = script.Parent
local frame = ScreenGUI.Frame
local TextLabel = frame.TextLabel

for i = 1, 10, 1 do

    frame.BackgroundTransparency = frame.BackgroundTransparency + 0.1
    TextLabel.BackgroundTransparency = TextLabel.BackgroundTransparency + 0.1
    TextLabel.TextTransparency = TextLabel.TextTransparency + 0.1
    wait(0.1)

end

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