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: KeyDown/KeyUp

Previous Thread :: Next Thread 
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
13 Oct 2013 06:19 PM
Is KeyDown fired when a player holds a key down and KeyUp when they release a key?
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
13 Oct 2013 06:19 PM
Yes.
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
13 Oct 2013 06:21 PM
Not holds, just when they press it.
Report Abuse
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
13 Oct 2013 06:27 PM
Well, mine won't stop when I release the key.

Here's my code:

mouse = game.Players.LocalPlayer:GetMouse()
w = false

function key(key)
if key == "w" then
w = true
while true do
if w == true then
--code
end
end
end
end

function unkey(key)
if key == "w" then
w = false
end
end

mouse.KeyDown:connect(key)
mouse.KeyDown:connect(unkey)
Report Abuse
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
13 Oct 2013 06:27 PM
Oh.
Report Abuse
qrrrq is not online. qrrrq
Joined: 27 Jan 2013
Total Posts: 1252
13 Oct 2013 06:28 PM
Well, is there one for when a key is held?
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
13 Oct 2013 06:32 PM
local Keys,Player={},Game:GetService("Players").LocalPlayer;function x(y,z)Keys[y]=z;end;
local Mouse=Player:GetMouse(); Mouse.KeyDown:connect(function(k)x(k,true)end)Mouse.KeyUp:connect(function(k)x(k,false)end);

Then:

Mouse.KeyDown:connect(function(Key)
if Key ~= "w" then return end
while Keys['w'] and wait(1/30) do
print'w is down'
end
end
end)
Report Abuse
Iterations is not online. Iterations
Joined: 22 Jul 2013
Total Posts: 751
13 Oct 2013 06:32 PM
Remove the second to last end, apologies.
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