I am trying to make a menu for my game.
This is my code
local function onClick() script.Parent.Visible = false script.Parent.Parent.MainMenu.Visible = true end script.Parent.MouseButton1Click:Connect(onClick) script.Parent.SettingsButton.MouseButton1Click:Connect(onClick)
This is the error: MouseButton1Click is not a valid member of Frame "Players.FireTap1.PlayerGui.MenuGui.Menu"
Your script is fine, the issue is what you're referencing.
script.Parent.MouseButton1Click:Connect(onClick)
The error is saying MouseButton1Click isn't applicable to Frames, because they cant be clicked. You need to reference an imagebutton or a textbutton instead.
You got a error, you need to detect the visiblity, heres the script am mean:
local function onClick() if script.Parent.Parent.MainMenu.Visible == true then script.Parent.Parent.MainMenu.Visible = false else script.Parent.Parent.MainMenu.Visible = true end end script.Parent.MouseButton1Click:Connect(onClick) script.Parent.SettingsButton.MouseButton1Click:Connect(onClick)
If you don't want to make it visible when it falls (button opens an invisible frame then visible then again), Heres another script:
local function onClick() if script.Parent.Parent.MainMenu.Visible == true then script.Parent.Parent.MainMenu.Visible = false end end script.Parent.MouseButton1Click:Connect(onClick) script.Parent.SettingsButton.MouseButton1Click:Connect(onClick)
Hope it help's!