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 » Scripting Helpers
Home Search
 

Re: Double Mouse1Button? [Help?]

Previous Thread :: Next Thread 
TinpotOps is not online. TinpotOps
Joined: 22 Jul 2012
Total Posts: 813
22 Oct 2012 12:47 PM
There's a few games that I've been to that have GUIs to where you click them once with the left mouse button (MouseButton1), and they'll do some type of operation, and then you're able to click them again with the same button (MouseButton1), and it'll go back to how it was origianlly before.

how to get this?

Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 12:54 PM
Like a show/hide toggle?

script.Parent.MouseButton1Down:connect(function()
if gui.Visible then
--blah
else
--blah
end
end)
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
22 Oct 2012 12:55 PM
Haven't tested this, just typed it now, but it should work.


Dub = 0
Button = script.Parent

function DoubleClicked()
print(Button,"double clicked")
end

Button.MouseButton1Click:connect(function()
Dub = Dub+1
if(Dub==2)then
DoubleClicked()
end
end)

while(wait(.1))do
Dub = 0
end
Report Abuse
nominate10 is not online. nominate10
Joined: 20 May 2008
Total Posts: 2545
22 Oct 2012 12:56 PM
some example code..

local lastClick = 0

function button1clicked()
if lastClick - workspace.DistributedGameTime <= 0.7 then
-- double click
end
lastClick = workspace.DistributedGameTime
end



The concept here is to record the time of the last click, and find the time elapsed since then on the next click. If the difference is small enough, that means they clicked in rapid succession.
Report Abuse
nominate10 is not online. nominate10
Joined: 20 May 2008
Total Posts: 2545
22 Oct 2012 12:57 PM
@1topcop

Your code works, however the user could click once, wait 5 minutes, and click again and have it counted as a double click.
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 12:58 PM
I think the title was misleading; not sure if he's after double-clicks or toggles.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
22 Oct 2012 12:59 PM
No it wouldn't, I'm looping it to 0 every .1 seconds, figuring double click will take less then .1 seconds.
Though, I like your code better, hadn't thought of doing that.
Report Abuse
nominate10 is not online. nominate10
Joined: 20 May 2008
Total Posts: 2545
22 Oct 2012 01:00 PM
Just re-read, and you're right. Sorry.


In that case, just have a variable store a bool-value to check if the first operation was completed or not, kinda like SourceLeak's example.
Report Abuse
nominate10 is not online. nominate10
Joined: 20 May 2008
Total Posts: 2545
22 Oct 2012 01:04 PM
And @1topcop

Apparently I'm blind on this thread, xD I seem to have skipped over your last few lines. But even still, I like to avoid using while loops wherever I can to reduce lag in the game. :)
Report Abuse
bigmotorsicklemax is not online. bigmotorsicklemax
Joined: 06 May 2012
Total Posts: 19
22 Oct 2012 01:05 PM
Use MouseButton1Down.
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 01:05 PM
@big

That barely begins to answer the question.
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 01:07 PM
OP got either modbotted or floodchecked.
Report Abuse
TinpotOps is not online. TinpotOps
Joined: 22 Jul 2012
Total Posts: 813
22 Oct 2012 01:10 PM
Modbotted, won't even let me post a simple script.
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 01:11 PM
Put it on pastebin and give us the id
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 01:12 PM
not the link

._.
Report Abuse
TinpotOps is not online. TinpotOps
Joined: 22 Jul 2012
Total Posts: 813
22 Oct 2012 01:12 PM
TnRkcZmy
Report Abuse
SourceLeak is not online. SourceLeak
Joined: 10 Jun 2012
Total Posts: 841
22 Oct 2012 01:18 PM
KiyfWEkK
Report Abuse
TinpotOps is not online. TinpotOps
Joined: 22 Jul 2012
Total Posts: 813
22 Oct 2012 01:22 PM
Alrighty, thanks man! +1 to you.
Report Abuse
Woodstauk4 is not online. Woodstauk4
Joined: 27 Dec 2010
Total Posts: 3061
22 Oct 2012 02:22 PM
local time=0
script.Parent.MouseButton1Down:connect(function()
if time-tick()<1 then
--code
else
time=tick()
end
end)


efficiency counts <:
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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