UI Buttons Close/Open Issue

how would I go about making a LocalScript where if a player clicks a UI ImageButton (via ‘ButtonsFrame’ and it’s children) and then clicks another button it closes the frame (via UIsFrame) they had opened?

  1. Player clicks on ImageButton (let’s say ButtonsFrame.CodeButton)
  2. UIsFrame.CodeFrame becomes visible.
  3. Player then clicks another ImageButton (ButtonsFrame.ShopButton)
  4. Now both the Codes UI and the Shop UI are visible.
  5. The issue: How do i make the Codes UI invisible when the player clicks the ShopButton, and when the player clicks the CodeButton the Shop UI goes invisible.

i’ve already tried looking on websites like the DevForum to no avail as people i’ve seen ask the same question has had a completely different directory setup compared to mine

image

Thanks in advance!

Visible… on the frame should also hide/show all the set visible children within it.
Part of pressing the CodeButton could also use that to hide the ShopFrame.

toggle
local buttonsFrame = script.Parent
local uiFrame = game.Players.LocalPlayer.PlayerGui.UIFrame
local codeButton = buttonsFrame.CodeButton
local shopButton = buttonsFrame.ShopButton
local codeFrame = uiFrame.CodeFrame
local shopFrame = uiFrame.ShopFrame

codeButton.MouseButton1Click:Connect(function()
    codeFrame.Visible = true
    shopFrame.Visible = false
end)

shopButton.MouseButton1Click:Connect(function()
    shopFrame.Visible = true
    codeFrame.Visible = false
end)

Just a toggle example.
This is not following your UI set up (I can’t see all of it).

1 Like