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: Question:Keydown

Previous Thread :: Next Thread 
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
02 Jul 2014 07:01 PM
I made keydown and i am not sure what is wrong here

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
if key == "a" and key == "z" then
print("b")
end
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
02 Jul 2014 07:02 PM
You need to make an event for the button press. In this case, the KeyDown event will do the trick.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
if key == "a" and key == "z" then
print("b")
end
end)

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
02 Jul 2014 07:04 PM
No it doesnt working i tried ...
Report Abuse
super10099 is not online. super10099
Joined: 30 Jan 2010
Total Posts: 1102
02 Jul 2014 07:05 PM
-- I don't know how you would do for multiple keys at once, but this works for one key



local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
if key == "a" then
print("b")
end
end)
Report Abuse
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
02 Jul 2014 07:05 PM
if key == "a" and key == "z" then

One key can't be two values. Did you mean to have 'or' instead of 'and'?

-[::ƧѡÎḾḠΰῩ::]-[::Helper of Scripting and Writer of Wikis::]
Report Abuse
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
03 Jul 2014 07:19 AM
Dude i want to make multiple keys
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
03 Jul 2014 07:22 AM
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Keys = {}

Mouse.KeyDown:connect(function(key) Keys[key] = true end)
Mouse.KeyUp:connect(function(key) Keys[key] = nil end)

if Keys["a"] and Keys["z"] then
print("b")
end

~The herp lerped a derp~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2014 07:43 AM
@filip

That if will run most likely before any key presses.
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
03 Jul 2014 07:51 AM
That is for him to figure out by himself :P
I only did exactly what he told us to, he has to learn you know ._.

~The herp lerped a derp~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
03 Jul 2014 07:57 AM
Alright so give the noob to KeyDown a weird non-indented script, that will not do what he wanted, just so he can resort to giving up?

I hardly call that learning.

Nice coverup for you mistake though lol :P
Report Abuse
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
03 Jul 2014 10:56 AM
Seriously u think i didnt search before asking you... i tried come paste same script still it doesn't work


If you are not going to help me just leave this post
Report Abuse
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
03 Jul 2014 10:57 AM
#filiptibell

Good copy paste..
Report Abuse
filiptibell is not online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
03 Jul 2014 11:31 AM
I use this all the time, so I copied it and pasted here from one of my places
What's your point ._.

~The herp lerped a derp~
Report Abuse
Aisoc is not online. Aisoc
Joined: 08 Jun 2013
Total Posts: 412
03 Jul 2014 12:09 PM
Post closed.
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
03 Jul 2014 12:22 PM
keyz = {}
mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function(K)
keyz[K] = true--tells us that this key is held
if keyz['a'] and keyz['z'] then--if both a and z are held down then
print('b')
end
end)
mouse.KeyUp:connect(function(K)
keyz[K] = false--tells us the key is now up
end)
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