How would I make a Fade Out button for a GUI?

I need help to make a button that fades out a Frame/Gui in my intro screen.

The script I’m using:

Screen Shot 2020-10-31 at 1.52.30 PM

Screen Shot 2020-10-31 at 1.52.40 PM

1 Like

The button is called FadeOutButton, yet you wrote TextButton. Change that name in the code. :slight_smile:

You can also use TweenService.

local TS = game:GetService("TweenService")
script.Parent.Parent.FadeoutButton.MouseButton1Click:Connect(function()
    local Tween = TS:Create(script.Parent, TweenInfo.new(1), {BackgroundTransparency = 1})
    Tween:Play()
    Tween.Completed:Connect(function()
    --make something happen when the tween finishes if you want
    end)
end)
1 Like

When I do that, The button fades and not the frame it self.

You want the frame to fade? If so, then change TextButton to Frame and make sure you are getting the right hierarchy in the GUI. Maybe you might need to remove a .Parent or something. Also, like @bluddbrain said, TweenService would be great to use for something like this :slight_smile:

If the script is in the TextButton and you’re fading out script.Parent then it’s only going to fade out the button. If you want the frame then change it to script.Parent.Parent

1 Like

Oh wait I misread the code sorry! Anyways, keep the text button code for that. Then make sure you are fading out the frame and not the button.

Is this right?

Screen Shot 2020-10-31 at 2.10.42 PM

Change the top script.Parent.Parent back to script.Parent and change the one in the loop to script.Parent.Parent and I think it should work?

1 Like

it worked thank you

at this point, when you press it the background does fade away. But, the button stays on the screen. How would I fix that?

You can make the button’s .Visible set to false.

You could delete the GUI or make it not visible once the loop finishes, but this might look weird if you aren’t making the button fade out too, so

for loop = 1,10 do
wait(0.1)
script.Parent.Parent.BackgroundTransparency = loop/10
script.Parent.BackgroundTransparency = loop/10
script.Parent.TextTransparency = loop/10
end
script.Parent.Parent.Visible = false
1 Like

Also you might want to add a debounce so you can’t make it fade out multiple times.
Also sorry about the weird formatting I can’t use tab on this menu

local d = false
if not d then
d = true
for loop = 1,10 do
wait(0.1)
script.Parent.Parent.BackgroundTransparency = loop/10
script.Parent.BackgroundTransparency = loop/10
script.Parent.TextTransparency = loop/10
end
script.Parent.Parent.Visible = false
end
1 Like

Would I add this to the current script, or make a new one. If so which script? Local, or just a script?

Replace the current loop part of the script with it

It won’t work.

Screen Shot 2020-10-31 at 2.23.15 PM

Add an end) to the bottom if there isn’t one already

It worked, thank you so much.
30char

1 Like