How to link fade on click?

hello again! ive been looking at gui scripts and tween stuff in the forums looking for help and even just watching lessons but i havent really found anything with this so here i go…
ive been learning and looking on how to link guis to do stuff on click and now i want it to all fade out but i also made the buttons move and fade in at different timings for effect heres my screen and my gui setup…


here is the gui setup in explorer

as i think and hoped i stated above ive found nothing on the forums and i dont think i understand scripting to were i can identify it from youtube tutorials.

ive tried tweening it which broke it so i redid it but i think its having a frame appear over the buttons or somehow disable it so they cant light up when my mouse still runs over it or make a noise when i click it and a exit button on the frame so it like reverses if that makes sense lol

my main idea in general is to make the 3 bottom image buttons have a different thing on click but when the click everything fades for a whole new gui ut there is an exit button
this is my code for it to glow when my mouse runs over it

local TweenService = game:GetService("TweenService") -- this will get tweenservice
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

script.Parent.MouseEnter:Connect(function()
	TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 0}):Play()
end)

script.Parent.MouseLeave:Connect(function()
	TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 0.5}):Play()
end)

this is my code for it to fade in on start (ITS ALL different for the image buttons and label

local pressed = true

local TweenService = game:GetService("TweenService") -- this will get tweenservice
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut)

repeat wait() until game:IsLoaded() 

wait(4.5) 

TweenService:Create(script.Parent, tweenInfo, {ImageTransparency = 0.5}):Play() 

wait(1) -- This will wait for the tween to be done.

local pressed = false
2 Likes

i hope the scripts helped in a way just a little

Idk should work.

local Frame = script.Parent

local function Fade()
    for i = 1,10 do
         Frame.BackgroundTransparency = Frame.BackgroundTransparency + 0.1
         wait(0.1)
    end
end
2 Likes

So, you want the frame to fade when pressing a button right?

well in all honestly, i dont know how it would work or how it would but im trying to make the buttons fade and not work so i can have a new gui and exit button

So, you want the button to fade out and have a new button fade in when clicked. Is that correct?

yes that correct, my idea was for it to all fade out that faded background stays and a scrolling gui with buttons and an exit button

Ok, I see now. That isn’t too hard to do actually. So, first, you want to fade out the background for the button:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.BackgroundTransparency = 0.1
    wait()
    script.Parent.BackgroundTransparency = 0.2
    wait()
    script.Parent.BackgroundTransparency = 0.3
    wait()
    script.Parent.BackgroundTransparency = 0.4
    wait()
    script.Parent.BackgroundTransparency = 0.5
    wait()
    script.Parent.BackgroundTransparency = 0.6
    wait()
    script.Parent.BackgroundTransparency = 0.7
    wait()
    script.Parent.BackgroundTransparency = 0.8
    wait()
    script.Parent.BackgroundTransparency = 0.9
    wait()
    script.Parent.BackgroundTransparency = 1
end

Then you want to fade out the text transparency. This can be a separate script if you want:

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.TextTransparency = 0.1
    wait()
    script.Parent.TextTransparency = 0.2
    wait()
    script.Parent.TextTransparency = 0.3
    wait()
    script.Parent.TextTransparency = 0.4
    wait()
    script.Parent.TextTransparency = 0.5
    wait()
    script.Parent.TextTransparency = 0.6
    wait()
    script.Parent.TextTransparency = 0.7
    wait()
    script.Parent.TextTransparency = 0.8
    wait()
    script.Parent.TextTransparency = 0.9
    wait()
    script.Parent.TextTransparency = 1
end

Then I recommend for the other button, you make a varible out of it and do the exact samething I wrote but make it fade in.

Quick thing I noticed.

Right now, your checking constant has the game loaded. The better solution would be to check, and if it’s not loaded wait for it to be loaded.

if not game:IsLoaded() the
game.Loaded:Wait()
end

forgive the formatting, I’m on mobile.

Also, if you save the tween to a variable and call that to play it, you would be able to listen to a .Completed event for more accurate timing.

oh im sorry i must have concussed you lol i do apologize for that inconvenience i meant the buttons go but this image label stays

Then just make make that function I made for you but just assign the function to the other buttons besides the image label.

I’d reccomend looking into tween service ri replace constantly wait() then set transparency, as tweenservice gusrantees a smooth transition.

1 Like

I could use that in the future. I’m just use to that method.

I highly reccomend you use tweenservice over that. It’s smooth, much easier to setup, and looks better.

1 Like

is there a way to link it to other buttons and labels? also yes thanks for recommending!

The way that I think you can do is just to make separate functions for each element.

I think what you should do is define a book value inside one of the frames, and whenever one button is clicked change the value to false so any of the tweens tween I’ve buttons stop and don’t break anything. From there, you should be able to just tween the three text transparencies.

Do you mean a bool value for what you are trying to say?

Since it’s all on different scripts, you would do that to store if one of the three has been pressed inside of a bool value instance, so you would be able to check for that and not highlight the other buttons when you hover over them.

1 Like

wow that makes sense! but how would i even begin to format it? it seems like i really big thing for a beginner scripter to try and start doing