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
 

For UserInputService and GetKeysPressed()

Previous Thread :: Next Thread 
Qivr is not online. Qivr
Joined: 22 Aug 2014
Total Posts: 5407
07 Jun 2015 06:59 PM
What would you use to fire the script?

Like, GetKeysPressed() returns an array of the keys currently being pressed.

This is what I have, but it doesn't work.

local player = game.Players.LocalPlayer

local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function()
local keysPressed = UIS:GetKeysPressed()
for i,v in pairs(keysPressed) do
if v == "f" then
print('Fired')
end
end
end)
Report Abuse
Qivr is not online. Qivr
Joined: 22 Aug 2014
Total Posts: 5407
07 Jun 2015 07:08 PM
Oh wait, the problem might be that it's in KeyCodes...
Report Abuse
Qivr is not online. Qivr
Joined: 22 Aug 2014
Total Posts: 5407
07 Jun 2015 07:09 PM
I changed if v=="f" then to 'if v==102 then'

still doesn't work ;P
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
07 Jun 2015 07:12 PM
It returns the actual inputObjects.

--

local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function()
local keysPressed = UIS:GetKeysPressed()
for i,v in pairs(keysPressed) do
if v.KeyCode.Name == "F" then
print('Fired')
end
end
end)
Report Abuse
Qivr is not online. Qivr
Joined: 22 Aug 2014
Total Posts: 5407
07 Jun 2015 07:14 PM
Oh! Thank you! It works.
Report Abuse
Lacrase is not online. Lacrase
Joined: 14 Jan 2015
Total Posts: 12706
07 Jun 2015 07:55 PM
stupid qivr
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