Method "MouseButton1Click" Deprecated?

This script is giving me an error instead of doing what it’s supposed to. Is this method now deprecated?
The error says it’s on the last line. Is there a new way to call this function?

function leftClick()
	script.Parent.Parent.Shop.Frame.Visible=true
end

script.Parent.MouseButton1Click:Connect(leftClick)
1 Like

What exactly is “script.Parent”? Can you also clarify what the error is?

1 Like

What is the error? MouseButton1Click isn’t deprecated, so you’re probably connecting to it on an object it doesn’t exist for, like a ClickDetector.

3 Likes

script.Parent is an ImageButton
script.Parent.Parent.Shop.Frame is the frame I want to display.

1 Like

local button = script.Parent
local frame = script.Parent.Parent.Shop.Frame

function Clicked (mouse)
frame.Visible = true
button.Visible = false
end
button.MouseButton1Click:Connect (Clicked)

1 Like

I did that code and got this error:
20:45:53.389 - MouseButton1Click is not a valid member of ImageLabel

Also I changed script’s S on line 2 to lowercase.

1 Like

That means you aren’t using an ImageButton but rather an ImageLabel, change them out and it will work

2 Likes

You said it is an imagebutton but why the error showed it is an imagelabel?

1 Like

Here’s the script if you put it into the imagebutton.

function leftClick()
script.Parent.Parent.Shop.Frame.Visible = true
end

script.Parent.MouseButton1Click:Connect(leftClick)
1 Like

It was an ImageLabel, it will work now I don’t know how I didn’t realize.

1 Like

Maybe try it on another Gui, like.

button = script.Parent
gui = script.Parent.Parent.Parent.ShopFrameGui

function clicked (mouse)

button.Visible = false
ShopFrameGui.Enabled = true
end
button.MouseButton1Click:Connect (clicked)

1 Like