✓ Accepted answer
EDIT: To disable every button, you can get every descendant of the player's PlayerGui using GetDescendants() and check if it's an ImageButton or a TextButton using IsA("GuiButton"). To get the PlayerGui from the script, you can use script:FindFirstAncestorOfClass("PlayerGui").
local AboutBtn = script.Parent
local AboutFrame = AboutBtn:WaitForChild("AboutFrame")
local PlayerGui = script:FindFirstAncestorOfClass("PlayerGui")
repeat
PlayerGui = script:FindFirstAncestorOfClass("PlayerGui")
task.wait()
until PlayerGui
local debounce = true
AboutBtn.MouseButton1Click:Connect(function()
if debounce then
debounce = false
AboutFrame.Visible = not AboutFrame.Visible
for _, descendant in ipairs(PlayerGui:GetDescendants()) do
if descendant:IsA("GuiButton") and descendant ~= AboutBtn then
descendant.Visible = AboutFrame.Visible
end
end
debounce = true
end
end)
OLD: @666_brithday didn't properly explained his answer, so this answer is an improved version of his answer.
MouseButton1Click fires when the button was clicked and released using the left mouse button. This is a combination of MouseButton1Down (when the player clicks the button but haven't release the left mouse button) and MouseButton1Up (when the player releases the left mouse button in the button after holding the left mouse button). This event also works in mobile devices.
An alternative is Activated, which is like MouseButton1Click and MouseButton2Click (right mouse button), except that it can work in any UserInputType other than the left and right mouse button, such as MouseButton3 (pressing the mouse wheel), MouseWheel (scrolling the mouse wheel), and Touch (pressing the mobile screen).
And I also fixed his script:
local AboutBtn = script.Parent
local AboutFrame = AboutBtn:WaitForChild("AboutFrame")
AboutBtn.MouseButton1Click:Connect(function()
AboutFrame.Visible = not AboutFrame.Visible
end)
3 comments
TYSM! It worked finally but now I wanna ask how I make the other buttons on the screen disappear, like every button except the about button when the frame pops up.
Sure, I'm gonna edit my answer.
Done!