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
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
| |
|
|
| 13 Oct 2013 06:21 PM |
| Not holds, just when they press it. |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 27 Jan 2013 |
| Total Posts: 1252 |
|
| |
|
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 |
|
|
|
| 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 |
|
|
|
| 13 Oct 2013 06:32 PM |
| Remove the second to last end, apologies. |
|
|
| Report Abuse |
|
|