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
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
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
how do i make this so it happens when it is clicked though?
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
just wrap it in a button.Activated:Connect(function() --Code here end)