So I'm trying to detect when the mouse is clicked every time, but certain GUI objects like TextButtons
and TextBoxs
get in the way of this. I tried using UserInputService
, but apparently there's no registered key for mouse inputs.
Is there any way of detecting when the mouse is clicked, even if it's being clicked over a TextButton
or TextBox
? Because apparently clicking either of these GUI objects hides the click event from Button1Down
/ Button1Up
on the PlayerMouse
.
If anyone could provide an example, or even determine whether it's possible or not, I'd really appreciate it.
You were on the right track to start off with. All we need here is to use the UserInputService. I just tested it using the InputBegan
event, and it works fine.
All we need to do is get the UserInputService, then check when the event fires and see what type of input was used.
Here's an example code (In a LocalScript) :
local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(Input) if Input.UserInputType == Enum.UserInputType.MouseButton1 then --Checks to see if the input was the left mouse button print("The left mouse button was clicked!") end end)
And there you go, it's as simple as that!
Anyways, I hope this helped. If you have any further problems/questions, please leave a comment below, and I'll see what I can do.