Make sure to have another visible and the other one not visible when starting
function switchButtons()
button1.Visible = not button1.Visible
button2.Visible = not button2.Visible
end
button1.MouseButton1Click:Connect(switchButtons)
button2.MouseButton1Click:Connect(switchButtons)
You can use the Button.MouseButton1Click event and the TextButton.Visible property. Here is an example of how you can do this:
local button1 = script.Parent
local button2 = button1.Parent:FindFirstChild("Button2")
button1.MouseButton1Click:Connect(function()
button2.Visible = true
end)
This code assumes that the two buttons are siblings in the hierarchy, with button1 being the TextButton that you want to press to make button2 appear. When button1 is clicked, the MouseButton1Click event is fired, and the Visible property of button2 is set to true , making it visible.
You can also use the TextButton.Text property to set the text displayed on the button, and the TextButton.Size property to set the size of the button. For example:
local button1 = script.Parent
button1.Text = "Click me"
button1.Size = UDim2.new(0, 100, 0, 50)
This code sets the text displayed on button1 to “Click me” and the size of button1 to 100 pixels wide and 50 pixels tall.
I was a bit confused about the part about the circle, but this is how I understood your question:
If you want to make the TextButton appear when you press any of the buttons with a circle around them, you can add the same event handler to each of those buttons. For example:
local buttons = script.Parent:GetChildren()
local button2 = script.Parent:FindFirstChild("Button2")
for _, button in pairs(buttons) do
if button:IsA("TextButton") and button.Name ~= "Button2" then
button.MouseButton1Click:Connect(function()
button2.Visible = true
end)
end
end
This code gets all the children of the parent object, filters out any that are not TextButtons or are Button2, and adds the event handler to each of the remaining buttons. When any of these buttons is clicked, the MouseButton1Click event is fired, and the Visible property of button2 is set to true , making it visible.