Minor problem with control text

com-video-to-gif%20(7)

As you can see in the gif. Clicking on the weapons tab, opens the side bar, and the ‘<’ becomes ‘>’ (to close) and clicking it again changes it back to ‘<’

However, if you click on one, and then click on the other, both will stay as ‘>’ How can I go about fixing that up?

for _, v in pairs(frame:GetChildren()) do
	if v:FindFirstChild('Select') then
		local button = v.Select
		button.Activated:Connect(function()
			if button.Backing.Open.Text == '<' then
				button.Backing.Open.Text = '>'
				scrolling.Visible = true
				backing.Visible = true
			else
				button.Backing.Open.Text = '<'
				scrolling.Visible = false
				backing.Visible = false
			end
		end)
	end
end
1 Like

You could run another for loop inside the button click event to see if any other buttons have their text as “>”, if they do change it to “<” and close the GUI that appears before moving on.
Alternatively you could handle each button separately inside the for loop and add a check to see if that specific button was clicked and is currently showing it’s respective GUI - if it is, close it, then respond to the player clicking the other button.

1 Like

You can close all guis when one button is clicked, then just show that one.

for _, v in pairs(frame:GetChildren()) do
	if v:FindFirstChild('Select') then
		local button = v.Select
		button.Activated:Connect(function()
			if button.Backing.Open.Text == '<' then
                                for _,v in pairs(frame:GetChildren()) do
                                    local button1 = v.Select
                                    button1.Backing.Open.Text = '<'
                                    scrolling.Visible = false
                                    backing.Visible = false
                                end
				button.Backing.Open.Text = '>'
				scrolling.Visible = true
				backing.Visible = true
			else
				button.Backing.Open.Text = '<'
				scrolling.Visible = false
				backing.Visible = false
			end
		end)
	end
end
3 Likes