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 » Scripters
Home Search
 

Re: Question about :KeyDown()

Previous Thread :: Next Thread 
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
19 Aug 2015 01:22 AM
Is there a way to return when 2 keys are pressed at the same time? Like if you only wanted sprinting by holding shift to work when you press w, a, s, or d with it? Sorta like this?

mouse.KeyDown:connect(function(key1, key2)
print(tostring(key1).." and "tostring(key2).." were pressed!")
end)
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 01:23 AM
http://wiki.roblox.com/index.php?title=API:Class/UserInputService/GetKeysPressed

UIS > .KeyDown/.KeyUp
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
19 Aug 2015 01:24 AM
oh my, thank you kind sir.
Report Abuse
jtefurd is not online. jtefurd
Joined: 01 May 2010
Total Posts: 952
19 Aug 2015 01:31 AM
Erm, having trouble attempting to just make it print the amount of keys being pressed at once. Examples anyone? qq
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 01:38 AM
never tried using the :GetKeysPressed() method, but i'll give it a shot

local uis = game:GetService("UserInputService")
uis.InputBegan:connect(function(input, gpe)
local keys = uis:GetKeysPressed()
if not gpe and #keys > 0 then
for i, v in ipairs(keys) do
print(game.Players.LocalPlayer.Name.." has pressed "..v.KeyCode.Name)
end
end
end)

try that?
Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
19 Aug 2015 01:40 AM
*print(game.Players.LocalPlayer.Name.." has pressed "..tostring(v.KeyCode))

no idea where .Name came from for v.KeyCode
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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