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: Mouse clicked while holding a key.

Previous Thread :: Next Thread 
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
17 Oct 2013 09:04 AM
is it possible to create a function that when you click the mouse while holding a key, it would make a function like this:

mouse.Button1Down:connect(function(key)
if key == "c" then
-- action here
else
--other action here
end
end)
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
17 Oct 2013 09:08 AM
local keys = {}

mouse.Button1Down:connect(function()
if keys["c"] then
--action here
else
--other action here
end
end)

mouse.KeyDown:connect(function(key)
keys[key] = true
end)

mouse.KeyUp:connect(function(key)
keys[key] = nil
end)
Report Abuse
chaokid9 is not online. chaokid9
Joined: 29 Aug 2008
Total Posts: 6187
17 Oct 2013 09:09 AM
This isn't proper syntax, but I would do something like this:

CDOWN = false
Onkeydown()
if key == "c" then
CDOWN = true
end

OnKeyup()
if key == "c" then
CDOWN = false
end

OnClick()
If CDOWN == true then
--What you want
else
print("You clicked, but C was not held down")
end
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
17 Oct 2013 09:14 AM
Ehh, yeah good logic, tho no proper syntax.
Report Abuse
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
17 Oct 2013 09:32 AM
well then what is proper syntax?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
17 Oct 2013 09:32 AM
You missed my first post, or what?
Report Abuse
SpecterSlash is not online. SpecterSlash
Joined: 29 Aug 2009
Total Posts: 629
17 Oct 2013 10:05 AM
no I mean, like what is the difference between your script and his script?
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
17 Oct 2013 10:11 AM
He had proper idea/logic, but not syntax of code. And his code would only detect one key, but I made so you can check if any other key is down, if you need it for later use.
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