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: Get Mouse

Previous Thread :: Next Thread 
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 10:06 PM
How do I use GetMouse with keydown?
Report Abuse
ScripterFTW is not online. ScripterFTW
Joined: 17 Aug 2012
Total Posts: 1450
29 Sep 2012 10:45 PM
you didn't explain anything nobzr
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 10:46 PM
What? I am asking how to do it.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:01 PM
Does anyone know how?

I really need this.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
29 Sep 2012 11:02 PM
-- local script
local p = Game.Players.LocalPlayer
local mouse = p:GetMouse()

mouse.KeyDown:connect(function(k)
-- Code
end)
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:02 PM
So is the letter "k", the key that it is detecting?
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:04 PM
ITS THE SAME MOUSE AS BEFORE THAT YOU WOULD GET FROM TOOLS AND HOPPERBINS. THE SAMMMMMEEEEEE MOUSSSSEEEEE.

There needs to be a sticky about this... Because I thought it was obvious. But no one else does. You use the same events and properties that you did with the old mouse. The only change is that you can access it from any local location...
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:05 PM
Well, I never used the old mouse, so I would not know that.
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:06 PM
http://wiki.roblox.com/index.php/Mouse

Enjoy. Google is a wonderful tool; use it first because it requires no extra human effort and is therefore the most efficient.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:07 PM
Thank you.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
29 Sep 2012 11:08 PM
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.KeyDown:connect(function(key)
if key:lower() == "k" then
print(key)
else
print(key .. " is nil")
end
end)
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:09 PM
Thanks, for another way to do it!
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:09 PM
I really wish people would stop preaching the if key:lower() == "?" then thing... It makes no sense to me...
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
29 Sep 2012 11:13 PM
@aboy so basically if the key is upper caps or lower caps then print the key
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:14 PM
No your thing says:

if the key being pressed is the "k" key then
print "k"
otherwise print the key being pressed is nil

That makes 0 sense...
Report Abuse
ElectricBlazeAlt is not online. ElectricBlazeAlt
Joined: 17 Aug 2012
Total Posts: 3535
29 Sep 2012 11:15 PM
@unholysoda - What are you talking about? The only difference is that the argument's name is different.

@aboy - How doesn't it make sense? It's straight-forward.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:16 PM
@aboy5643
With your way, it will print the text, no matter what key is pressed.
With his way, it only will print, if the key you want is pressed.
Report Abuse
ElectricBlazeAlt is not online. ElectricBlazeAlt
Joined: 17 Aug 2012
Total Posts: 3535
29 Sep 2012 11:17 PM
Except that nil part that he used.
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
29 Sep 2012 11:17 PM
"ITS THE SAME MOUSE AS BEFORE THAT YOU WOULD GET FROM TOOLS AND HOPPERBINS. THE SAMMMMMEEEEEE MOUSSSSEEEEE."
Actually, the game.Players.LocalPlayer:GetMouse() function returns a mouse which cannot have its icon set. Lame!

I had to still use the "Hey, select this tool!" method of getting the mouse in my current game! :P
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:18 PM
Why would you need to check for the lowercase version of the key being pressed? All keys being pressed are lowercase by default T_T You don't need to check it to a lowercase version of the key being pressed... It's just a waste of a conditional and marginable speed....
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:18 PM
Well for what I am trying to do, @thedeathmaster01 method worked, whole the other guys method did not.
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:19 PM
@blobbyblob

According to devs in scripters, that's an unintended bug. But otherwise it is the same mouse object... It's just some artifact stuff that was making the port not work correctly.
Report Abuse
unholysoda is not online. unholysoda
Joined: 15 May 2010
Total Posts: 9024
29 Sep 2012 11:22 PM
I have one more question.

How would I have something happen when they first press the button, and have something else happen, when they release the button?
Report Abuse
ElectricBlazeAlt is not online. ElectricBlazeAlt
Joined: 17 Aug 2012
Total Posts: 3535
29 Sep 2012 11:22 PM
@aboy - Oh, I didn't know you were only referring to the lowercase part; I thought you were talking about the whole line. Anyway, I'm not sure if this is correct, and I can't test it now because I can't install ROBLOX on this laptop, but maybe the key is uppercase if you're holding the shift button.
Report Abuse
aboy5643 is not online. aboy5643
Joined: 08 Oct 2010
Total Posts: 5458
29 Sep 2012 11:24 PM
@unholysoda

mouse.KeyUp:connect(function(keyBeingPressed)
--do stuff here
end)

@Electric

It doesn't... Left shift = 0 and Right shift = /. They don't modify the keys and http://wiki.roblox.com/index.php/KeyDown_(Event) <---- that page proves my point...
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