Need help on Play button for my GUI

Hello, I’m Gofe09 and I have very little knowledge on scripting.

Ive made this GUI with a play button in it:

Screenshot (7)

Here is the script for the play button:

But, when I click the play button the Main Menu GUI is still visible and clickable.

So I was wondering if I could get some help on why this wont work.

Here is a fixed version of your code!

local button = script.Parent -- variable 1  (defines the button instead of using "script.Parent")
local menu = button.Parent -- variable 2 (defines the menu for your button instead of using "script.Parent.Parent and such")

button.MouseButton1Down:Connect(function() -- detects when the player clicks on the button (must use function for the code to properly work)
	if menu.Enabled then -- checks if the menu is visible
		menu.Enabled= false -- makes menu invisible
	else
		return -- if menu is already invisible, then it will return the function yielding it from working
	end
	
end)

Using a ServerScript (Script) will work perfectly fine with this code inside of it

If you plan on using a ClientScript (LocalScript), it would probably be used for the player or using Services such as the UserInputService for example, which detects when a player presses something on their keyboard via mouse

Thank you so much this worked.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.