Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does Roblox Lua Not Have MouseButton1Click Anymore? Its Not Working For Me.

Hey there, so I am making a starting screen and I'm using a local script to manage it, but it says

07:24:35.065 - MouseButton1Click is not a valid member of ScreenGui

###Can anybody debunk this myth?

The script is inside my screen GUI holding everything that I am referencing to with locals. As well as plzplaybutton is a textbutton.

local screenGOOEY = script.Parent.screenthing
local playbutton = screenGOOEY.plzplaybutton

local function clicknomorescreenGOOEY()
	screenGOOEY.Visible = false
	print("screenGOOEY no longer visible hah")
end


script.Parent.MouseButton1Click:Connect(clicknomorescreenGOOEY)

Thanks,

Narwhal

1 answer

✓ Accepted answer

###Make sure to accept this answer if it solved your problem.

Question

Does Roblox Lua Not Have MouseButton1Click Anymore? Its Not Working For Me.

Answer

Yes, it does. The problem is found in your error.

07:24:35.065 - MouseButton1Click is not a valid member of ScreenGui

MouseButton1Click isn't a signal of ScreenGui's however it is a signal of TextButton's and such.

Instead, :Connect the .MouseButton1Click signal of a different object other than script.Parent since script.Parent is a ScreenGui such as a button.

In the case of your code you have a playbutton variable which is a TextButton so connect that.

playbutton.MouseButton1Click:Connect(<name of your function>)

Reading Resources

https://developer.roblox.com/en-us/api-reference/event/GuiButton/MouseButton1Click

https://developer.roblox.com/en-us/api-reference/class/TextButton

1 comment

1

Oh okay thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.