I wanna use MouseButton1Down so how do i do it?
This is what i've tried in a LocalScript but it didn't work:
1 | local Mouse = game.Players.LocalPlayer:GetMouse() |
2 |
3 | Mouse.MouseButton 1 Down:connect( function (Key) |
4 | script.Parent:CaptureFocus() |
5 | end ) |
Ok, so there answer above has no problem in it just that he didn't add the :Capture Focus Function
in there.... So just do this following code inside of a Local Script
under the TextBox
...
1 | local player = game.Players.LocalPlayer |
2 | local mouse = player:GetMouse() |
3 |
4 | mouse.KeyDown:connect( function () |
5 | script.Parent:CaptureFocus() |
6 | end |
MouseButton1Down
is an event of GUIs. This means you can only use it on TextButtons and ImageButtons (with the event firing when the gui is clicked).
mouse
has a separate event, which is just Button1Down
. You can use that.
1 | local mouse = game.Players.LocalPlayer:GetMouse() |
2 |
3 | mouse.Button 1 Down:connect( function () |
4 | print ( "clicked" ) |
5 | end ) |
Ok I got it to work, you never told me the localscript had to be in StarterGui LOL :D
1 | --Adornee is set to "Test" a part in game.Workspace |
2 |
3 |
4 | local mouse = game.Players.LocalPlayer:GetMouse() |
5 | mouse.Button 1 Down:connect( function () |
6 | if mouse.Target = = "Test" then |
7 | script.Parent:CaptureFocus() |
8 | end |
9 | end ) |