Mouse button error

I got error on this script


script.Parent.MouseButton1Click:Connect(function()

script.Parent.Parent:WaitForChild("Main").Visible = not script.Parent.Parent:WaitForChild("Main").Visible

end)

the error says… MouseButton1Click is not a valid member of ImageLabel “Players.DylTheDeveloperX.PlayerGui.ScreenGui.Main.Shop”

1 Like

Hello, use ImageButton, not ImageLabel

1 Like

I realize that after 40 seconds lol

Hello! Trying changing the shop button to ImageButton, as ImageLabel doesn’t have the ‘MouseButton1Click’ event attached to it.

Also, here is a more readable version of your code:

local Main = script.Parent.Parent:WaitForChild("Main")
local Button = script.Parent

Button.MouseButton1Click:Connect(function()
    Main.Visible = not Main.Visible
end)

I hope this helped you solve your issue! :slight_smile:

MouseButton1Click?
I don’t believe that’s correct.

local Main = script.Parent.Parent:WaitForChild("Main")
local Button = script.Parent

Button.MouseButton1Up:Connect(function()
    Main.Visible = not Main.Visible
end)

Yeah, it actually is to detect clicks, the problem is it was a ImageLabel rather than a ImageButton, and ImageLabel’s don’t have a MouseButton1Click event.