generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Re: Holding Mouse vs Clicking Mouse

Previous Thread :: Next Thread 
IthacaMedia is not online. IthacaMedia
Joined: 25 Jan 2014
Total Posts: 1337
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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
IthacaMedia is not online. IthacaMedia
Joined: 25 Jan 2014
Total Posts: 1337
26 Dec 2014 08:32 AM
Oh thanks lol, got used to mouse.Button1Click events xD.
Report Abuse
IthacaMedia is not online. IthacaMedia
Joined: 25 Jan 2014
Total Posts: 1337
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
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
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 is not online. 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 is not online. 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
IthacaMedia is not online. IthacaMedia
Joined: 25 Jan 2014
Total Posts: 1337
26 Dec 2014 12:20 PM
Ok thanks for the help.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image