UI Close after another opens

Well how am I supposed to get the Frame to open? I’m still not really understanding. Also I’m so sorry, I’m not great with code

It should open automatically since you’re calling the toggleUI function each time that button is pressed.

This line changes it from either true to false, or false to true: uis[targetFrame] = not uis[targetFrame]
It also closes each frame in that same function assuming the frame is to be opened.

So do I delete the script in the Button that makes the frame open?

Yeah, you shouldn’t need it since the script I wrote should handle open and closing.

So would there not be a problem if multiple things are called Value, and multiple things are all called Frame? Would I need to change it to like Frame1, etc?

No, it iterates through the children so duplicate names shouldn’t be an issue.

Do I rename the Text Button, or the ImageButton, value? Like which one do I rename.

You should have an ObjectValue inside each frame, then assign the ObjectValue’s value to be the “goal” button like this:

1 Like

So I make the TextButton my Value?

Yeah, exactly.

i’ve fixed the problem, so what you want to do is create a local script and put it in the image buttons
then add this:

script.Parent.MouseButton1Click:Connect(function()
	print("checking")
	for _, v in pairs (script.Parent.Parent.Parent.Parent:GetChildren()) do
		if v:IsA("Frame") then
			for _, nV in pairs(v:GetChildren()) do
				if nV:IsA("TextButton") then
					for _, v2 in pairs(nV:GetChildren()) do
						if v2:IsA("Frame") then
							if v2 == script.Parent.Parent.Frame then
								v2.Visible = not v2.Visible
							else
								v2.Visible = false
							end
						end
					end
				end
			end
		end
	end
	
end)

i have tested it and it’s 100% working, sorry if this took so long

I hope this helps!

2 Likes

Do I change this with the current localscript?

yes, can you tell me if it works?

2021-10-05 21-57-26 :relaxed:
(ignore the background sound), also, how can I remove the print it’s saying every time?)

you can just remove this line

This text will be hidden

Alright hey! I don’t actually need the help anymore, this other person came in clutch with a super simple option which I just did and it worked! I really did appreciate you trying to help me understand, again I’m so sorry, I am just really bad at trying to understand :laughing: Thanks for the time man!

1 Like

Alright, thank you! It did work, I am really appreciated :grinning_face_with_smiling_eyes:

1 Like

No problem! :smiley:

This text will be hidden

Maybe use method instead

Here’s Code Example :

Sorry there was a mistake

local TwitterFrame = script.Parent.TwitterFrame
local ShopFrame = script.Parent.ShopFrame
local InventoryFrame = script.Parent.InvenentoryFrame

TwitterFrame.MouseButton1Click:Connect(function()
    TwitterFrame.Visible = not TwitterFrame.Visible; ShopFrame.Visible = false; 
     InventoryFrame.Visible = false
end

ShopFrame.MouseButton1Click:Connect(function()
   ShopFrame.Visible = not ShopFrame.Visible; TwitterFrame.Visible = false; 
   InventoryFrame.Visible = false
end

InventoryFrame.MouseButton1Click:Connect(function()
    InventoryFrame.Visible = not InventoryFrame.Visible; TwitterFrame.Visible = false; 
    ShopFrame.Visible = false
end