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

[SOLVED] (?) Help with click functions in guis

It's been 3 years since I've consistently programmed in ROBLOX Lua, and thus the API has changed quite a bit since my hay day. I'm currently trying to get back into it, but I've run into a problem with GUIs.

I used to use this as a click function:

script.Parent.MouseButton1Down:connect(function()

end)

but now it seems to no longer work. I can't find any new documentation on the ROBLOX developer site, so I was curious as to whether there was something I was doing wrong. I have also tried using :connect and :Connect but capitalization does not appear to be the problem.

Thanks.

Solved - forgot when to use local scripts.

5 comments

0

Connect is correct, connect is deprecated, but either will work currently.

0

MouseButton1Down should also work. Local script?

0

@DinozCreates ah crap I forgot about local scripts. It's been while so I didn't even think about it, but I guess that makes sense. I'll try that out real quick.

0

Please mark as [Solved]

0

Don't forget to accept my answer if it helps.

1 answer

✓ Accepted answer

The only thing I can think of being the issue is that this code is in a script that is not a LocalScript. If this is in a server script, it will not work as server scripts will not run in PlayerGui. They used to run in there when experimental mode was still available, but experimental mode was removed in late July.

The FilteringEnabled property will not determine if experimental mode is active. It doesn't do anything now.

Also, you should use the GuiButton.Activated event rather than GuiButton.MouseButton1Down. The former is the recommended way of listening for GUI button clicks

2 comments

0

Too late.

0

Thanks for the advice. I'll accept this answer.

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