Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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.

0
Connect is correct, connect is deprecated, but either will work currently. DinozCreates 1070 — 6y
0
MouseButton1Down should also work. Local script? DinozCreates 1070 — 6y
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. msuperson24 69 — 6y
0
Please mark as [Solved] DinozCreates 1070 — 6y
0
Don't forget to accept my answer if it helps. User#24403 69 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

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

0
Too late. DinozCreates 1070 — 6y
0
Thanks for the advice. I'll accept this answer. msuperson24 69 — 6y
Ad

Answer this question