Skip to content
The Chat Archive
gpt-4o-2024-05-13· OpenAI WildChat-4.8M (AI2)

local function onButtonClick(button) if Exceptions[button.Name] then…

  1. User

    local function onButtonClick(button) if Exceptions[button.Name] then Exceptionsbutton.Name else local targetFrame = MainFrame.Parent:FindFirstChild(button.Name) if targetFrame and targetFrame:IsA("Frame") then if not targetFrame.Visible then targetFrame.Visible = true else targetFrame.Visible = false end else warn("Frame named '" .. button.Name .. "' not found.") end end end

    if any of the frames named 'Animation', 'Morph', 'Settings' and 'Walkspeed' become visible, make the others in this list not visible.

  2. Assistant

    To achieve the desired functionality, you can modify the onButtonClick function to loop through the list of specific frames ('Animation', 'Morph', 'Settings', 'Walkspeed') and set their visibility accordingly. Here is an updated version of the function:

    local specificFrames = {"Animation", "Morph", "Settings", "Walkspeed"}
    
    local function onButtonClick(button)
    	if Exceptions[button.Name] then
    		Exceptions[button.Name]()
    	else
    		local targetFrame = MainFrame.Parent:FindFirstChild(button.Name)
    		if targetFrame and targetFrame:IsA("Frame") then
    			if not targetFrame.Visible then
    				-- First, hide all specific frames
    				for _, frameName in ipairs(specificFrames) do
    					local frame = MainFrame.Parent:FindFirstChild(frameName)
    					if frame and frame:IsA("Frame") then
    						frame.Visible = false
    					end
    				end
    				
    				-- Then, make the target frame visible
    				targetFrame.Visible = true
    			else
    				targetFrame.Visible = false
    			end
    		else
    			warn("Frame named '" .. button.Name .. "' not found.")
    		end
    	end
    end
    

    Here's what the modification does:

    1. Define a list called specificFrames containing the names of your specific frames.
    2. When a button is clicked, check if the button.Name matches one in the Exceptions table. If so, execute the associated exception function.
    3. If there is no associated exception function, locate the target frame by its name in the frame's parent container (MainFrame.Parent).
    4. If the target frame is found and is a Frame object, determine its current visibility state.
    5. If the target frame is not visible:
      • Loop through the specificFrames list and hide any frame that is currently visible.
      • Make the target frame visible.
    6. If the target frame is already visible, simply hide it.
    7. If the target frame cannot be found, log a warning message.

    This approach ensures that only one frame from the specificFrames list is visible at a time, fulfilling the requirement you mentioned.