I wanna use MouseButton1Down so how do i do it?
This is what i've tried in a LocalScript but it didn't work:
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.MouseButton1Down:connect(function(Key)
script.Parent:CaptureFocus()
end)
I wanna use MouseButton1Down so how do i do it?
This is what i've tried in a LocalScript but it didn't work:
local Mouse = game.Players.LocalPlayer:GetMouse()
Mouse.MouseButton1Down:connect(function(Key)
script.Parent:CaptureFocus()
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 Scriptunder the TextBox...
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.KeyDown:connect(function()
script.Parent:CaptureFocus()
end
Um no it didn't print anything!
Well both of the scripts you've given me doesn't work is this a studio related glitch?
I think it's your studio because my script should work -_- I just now checked it and make sure your TextBox is under a ScreenGui or SurfaceGui please....
ok It's under a surfaceGui sorry for the long response, being busy lately
So did you figure it out?
No I think I need to use Adornee which idk how to use.
It's easy to use... You can do..... game.Workspace.Gui.Adornee = game.Workspace.Baseplate This means that the Gui will be on the baseplate
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.
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:connect(function()
print("clicked")
end)
Sadly that didn't work
It works, I tested it.
hm weird
what exactly isn't working about it?
Ok I got it to work, you never told me the localscript had to be in StarterGui LOL :D
--Adornee is set to "Test" a part in game.Workspace
local mouse = game.Players.LocalPlayer:GetMouse()
mouse.Button1Down:connect(function()
if mouse.Target == "Test" then
script.Parent:CaptureFocus()
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Forgot to mention that the LocalScript is a child of the TextBox
Are you trying to use a SurfaceGui or a BillBoardGui?