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)

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

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.

2 Likes

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

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)

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.

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

1 Like

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

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)

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

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)