Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make my AboutFrame visible when I click the AboutBtn?

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)

2 answers

✓ 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").

-- 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)

3 comments

0

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.

0

Sure, I'm gonna edit my answer.

0

Done!

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)

4 comments

0

I tried it, it still didn't work but I think I might've found the problem? There are two text labels that are inside the frame, maybe I need to incorporate them into the script?

0

That won't make a difference but maybe

0

I think the about button should be in the play button try moving about button into the frame

0

if you do that you need to change the .Parent in the script then

This discussion is preserved as it was. New answers, comments, and votes are closed.