I am trying to make a menu for my game.
This is my code
01 | local function onClick() |
02 |
03 | script.Parent.Visible = false |
04 | script.Parent.Parent.MainMenu.Visible = true |
05 |
06 |
07 | end |
08 |
09 | script.Parent.MouseButton 1 Click:Connect(onClick) |
10 | script.Parent.SettingsButton.MouseButton 1 Click: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.
1 | script.Parent.MouseButton 1 Click: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:
01 | local function onClick() |
02 |
03 | if script.Parent.Parent.MainMenu.Visible = = true then |
04 | script.Parent.Parent.MainMenu.Visible = false |
05 | else |
06 | script.Parent.Parent.MainMenu.Visible = true |
07 | end |
08 |
09 |
10 | end |
11 |
12 | script.Parent.MouseButton 1 Click:Connect(onClick) |
13 | script.Parent.SettingsButton.MouseButton 1 Click: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:
01 | local function onClick() |
02 |
03 | if script.Parent.Parent.MainMenu.Visible = = true then |
04 | script.Parent.Parent.MainMenu.Visible = false |
05 | end |
06 |
07 |
08 | end |
09 |
10 | script.Parent.MouseButton 1 Click:Connect(onClick) |
11 | script.Parent.SettingsButton.MouseButton 1 Click:Connect(onClick) |
Hope it help's!