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

How do I make a GUI fade away when it is clicked?

Asked by 1 year ago

Hello! In my game, I'm trying to make it so when you click a GUI button, it makes itself and other GUIs of my choice fade away. An answer would be much appreciated.

Thanks

2 answers

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

To make a gui fade, you can use the Transparency property of the elements like buttons, frames, labels, etc.

For your button to fade as well, you just have to change it's Transparency property at the same time.

An example for fading away:

object = --the object you want to fade out
transparency = 0 --starts as not transparent at all
while transparency <= 1
    object.Transparency = transparency -- set the transparency
    transparency += 0.05 -- make it a little more transparent
    wait(0.05) -- wait a little
end

For fading in, you just do the opposite:

object = --the object you want to fade in
transparency = 1 --starts as fully transparent
while transparency >= 0
    object.Transparency = transparency -- set the transparency
    transparency -= 0.05 -- make it a little less transparent
    wait(0.05) -- wait a little
end

If you want to make an entire ScreenGui fade out, you might do something like this:

ScreenGui = --put your Screen Gui object here
transparency = 0 --starts as not transparent at all
while transparency >= 1
    for _, object in ScreenGui:GetChildren() do -- Go through each object in the ScreenGui
        object.Transparency = transparency -- set the transparency
    end
    transparency += 0.05 -- make it a little more transparent
    wait(0.05) -- wait a little
end
Ad
Log in to vote
0
Answered by 1 year ago

how do i make this so it happens when it is clicked though?

0
just wrap it in a button.Activated:Connect(function() --Code here end) jgftr7 74 — 1y

Answer this question