I used this local script but it hasn't worked. There's no errors in the script analysis + I want to add the AboutFrame is not visible normally. Please don't judge I'm new to scripting.
Here is how my explorer looks
ScreenGui then PlayBtn inside the ScreenGui then the AboutBtn is inside the PlayBtn and the AboutFrame is in the AboutBtn
Do you think the issue might be that the AboutBtn has to be in the ScreenGui rather than the PlayBtn? Here's the local script as well.
local AboutFrame = script.child local AboutBtn = script.Parent
AboutBtn.MouseButton1Click:Connect(function() AboutFrame.Visible = not AboutFrame.Visible end)
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")
.
-- LocalScript inside AboutBtn local AboutBtn = script.Parent local AboutFrame = AboutBtn:WaitForChild("AboutFrame") local PlayerGui = script:FindFirstAncestorOfClass("PlayerGui") repeat -- if FindFirstAncestorOfClass returned nil/nothing (failed) PlayerGui = script:FindFirstAncestorOfClass("PlayerGui") -- we will define it again task.wait() -- so game doesn't crash/lag until PlayerGui -- until we got the PlayerGui (success) local debounce = true -- we will use a debounce so that we can give time for it to visible/invisible all buttons 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 -- if descendant is an ImageButton/TextLabel and not AboutBtn 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:
-- LocalScript inside AboutBtn local AboutBtn = script.Parent local AboutFrame = AboutBtn:WaitForChild("AboutFrame") AboutBtn.MouseButton1Click:Connect(function() AboutFrame.Visible = not AboutFrame.Visible end)
try this
local AboutFrame = script.Parent --Keep adding .Parents until you reach the AboutFrame local AboutBtn = script.Parent --Keep adding .Parents until you reach the AboutBtn AboutBtn.MouseButton1Click:Connect(function() AboutFrame.Visible = not AboutFrame.Visible end)