LocalWE
(WilliApple)
March 24, 2021, 11:10pm
#1
Hello! A former developer of mine uses GuiButton.Activated for GuiButtons, while I use MouseButton1Click.
Is there really a difference to using one or the other?
I mean… They have the same functionality, right?
If you see something different with one, please let me know. Thanks, WE
1 Like
Jxl_s
(Jxl_s)
March 24, 2021, 11:11pm
#2
They mostly have the same functionality, but Activated has an extra feature that allows you to see how many times a button was pressed, in a row.
4 Likes
GuiButton.MouseButton1Click only works for PC whereas GuiButton.Activated works for PC and mobile, very versatile.
LocalWE
(WilliApple)
March 24, 2021, 11:13pm
#4
MouseButton1Click works for all platforms. That is false.
1 Like
It doesn’t mention cross-platform input.
LocalWE
(WilliApple)
March 24, 2021, 11:18pm
#6
Well, I playtest my game on mobile, and it works all the time.
1 Like
Yup, it works for mobile my mistake. That’s strange how it’s called “MouseButton 1Click”.
1 Like
LocalWE
(WilliApple)
March 25, 2021, 2:23am
#9
My last question is, which one is less laggy?
synical4
(Synical)
March 25, 2021, 12:02pm
#10
Both are probably the same in performance. I don’t understand why these events would cause any lag at all?
2 Likes
fizxxr
(Fiz)
May 16, 2024, 2:30am
#12
I know I’m late but, mousebutton1click does work for mobile, BUT it doesn’t work for mobile in surfaceGUIs so if you’re using surfaceGUI’s, use Activated so both mobile and pc can click it.
2 Likes
From what I know theres 1 useful difference between them. If you use .Activated as an event listener then the function wont run IF the button is deactivated and clicked on. Whereas using the MouseButton1Click event listener will always run regardless of wether the button is Active or not if the player clicks on it.
1 Like
Since this thread was bumped, I’d like to bring up another key difference that no one else here has mentioned so far:
For the Activated
event:
The first parameter returns the InputObject
that was used to activate the button
(*The second parameter it returns is what the currently marked solution has mentioned, being how many times the button was clicked in a row).
The InputObject
Can be referenced to easily check a variety of things, including the UserInputType (such as MouseButton1, Touch, Gamepad1 , etc.).
Aside from that, here’s what I wrote a while back regarding which I prefer to use:
Personally, I’ve opted toward using Activated
over the other options ever since hearing the sentiment that it’s a better choice for supporting multiple types of inputs (e.g. mouse, touch, controller), which most likely stems from how it returns the inputObject .
Additionally, because it doesn’t mention a specific device in the event name like the MouseButton...
events do, it felt “safer” to use when wanting to be compatible with multiple input types (although I’m pretty sure that each of MouseButton1Click
, MouseButton1Down
, etc. work fairly consistently for multiple types of inputs).
1 Like