|
| 26 Dec 2014 08:26 AM |
| How do I keep track of both when the player clicks the mouse, and when they hold it down? |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2014 08:29 AM |
Here's how to detect both.
mouse.Button1Down:connect(function() print("holding mouse") end) mouse.Button1Up:connect(function() print("let go of mouse (click)") end) |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2014 08:32 AM |
| Oh thanks lol, got used to mouse.Button1Click events xD. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2014 08:34 AM |
| But wait, if they hold it down for a fraction of a second, will still count as holding mouse. |
|
|
| Report Abuse |
|
|
|
| 26 Dec 2014 08:50 AM |
mouse.Button1Down:connect(function() click = true --Detect if clicked print("click") wait(1) --Wait to detect if holding if click == true then click = false --If is holding then click becomes nil print("holding") --Where your code goes for what should happen if you're holding down mouse hold = true --Make holding true end end) mouse.Button1Up:connect(function() if click == true then print("click bye") --Where your code goes for what should happen if you lift mouse with click (Leave empty if nothing) click = false elseif hold == true then print("hold bye") --Where your code goes for what should happen if you lift mouse with hold (Leave empty if nothing) hold = false end end) |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 26 Dec 2014 09:08 AM |
-- Least lines and it doesn't fire if someone spams click which may trigger mouse hold.
holdspeed = 0.2
mouse.Button1Down:connect(function() local bool delay(holdspeed, function() if not bool then print'holding' end end) mouse.Button1Up:wait() print'released' bool = true end)
|
|
|
| Report Abuse |
|
|
Dominical
|
  |
| Joined: 04 Nov 2011 |
| Total Posts: 1303 |
|
|
| 26 Dec 2014 09:25 AM |
| This may or may not help you depending on your knowledge, but make a Timer with the Button1Down event. |
|
|
| Report Abuse |
|
|
| |
|