UI Close after another opens

Hello! I’m making my UI and I want to make it so it closes after another UI Is opened. Let’s say you open Twitter Codes, and you open another UI, and the other UI That you had opened closes. How can I do this? Are there any videos on how to do this?

1 Like

you can set other’s ui visibility to false after you enabled one ui

or you can run a for loop to disable all the ui and re enable the selected ui

Are there any videos on how to do that?

i don’t know, but can i see how your ui’s are parented? maybe i could help

Yea. Are you fine if I send you a video of my UI Stuff?

sure

This text will be hidden

2021-10-05 20-27-55 (jumpshare.com)

Screenshot 2021-10-05 203103

script.Parent.MouseButton1Click:Connect(function()
	if frame.Visible == false then
		frame.Visible = true
	elseif
		frame.Visible == true then
		frame.Visible = false
	end
end)

You can do a string value, then if it change and the name of local UI is not the same of Value, then it set visible to false

How would I exactly do that? Are there any videos?

wait. what frame do you want to disable, is it the text buttons?

or is it the frame (bottom,left,right)

The frames when you click the Text Buttons.
image

do you mean the frame you’re defining here?
can you tell me what frame exactly from the picture?

oh okay, wait

This text will be hidden

I can stream on discord if you want, it’ll be a lot easier. And yes.

so you can do it like this,

in a local script, add this script:

script.Parent.MouseButton1Click:Connect(function()
    for _, v in pairs(script.Parent.Parent.Parent:GetChildren()) do
        for _, nV in pairs(v:GetChildren()) do
            if nV:IsA("Frame") then
                for _, vv in pairs(nV:GetChildren()) do
                    if vv:IsA("TextButton") then
                        local nFrame = vv:FindFirstChild("Frame")
                        nFrame.Visible = false
                    end
                end
            end
        end
    end
    script.Parent.Frame.Visible = not script.Parent.Frame.Visible 
end)

now you should add the script in every button

oh and also, instead of checking if their are visible or not and then setting them their opposite value
you can do this instead,

Frame.Visible = not Frame.Visible

sorry if this took so long,

I hope this helps!

No worries haha. So do I replace this with the current Script?

yes, can you tell me if it worked?

Yea, give me a moment i’m doing something in a game