|
| 07 Feb 2015 09:22 PM |
Mouse.KeyDown:connect(function(key) if key == "d" then repeat num = num + 1 print(num) wait(.5) until key ~= "d" end end)
What this is supposed to do: While the user holds "d" on the keyboard, num is increased by 1 and is printed every .5 seconds. When the user lets go of "d" this should stop printing num and stop adding 1 to num.
What this actually does: When the user presses "d" num is printed and added to every .5 seconds, but when the user lets go of "d" it continues as if they were still holding it. Pressing "d" again will add to num and print num faster.
Help? |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 09:25 PM |
Mouse.KeyUp:connect(function()
end)
Join - http://www.roblox.com/My/Groups.aspx?gid=468509 |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 09:27 PM |
Basically heres what you need
local keyPressed = false
Mouse.KeyDown:connect(function(key) if key == "d" then keyPressed = true repeat num = num + 1 print(num) wait(.5) until keyPressed == false end end)
Mouse.KeyUp:connect(function(key) if key == "d" then keyPressed = false end)
Join - http://www.roblox.com/My/Groups.aspx?gid=468509 |
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 09:27 PM |
local keyPressed = false
Mouse.KeyDown:connect(function(key) if key == "d" then keyPressed = true repeat num = num + 1 print(num) wait(.5) until keyPressed == false end end)
Mouse.KeyUp:connect(function(key) if key == "d" then keyPressed = false end end)
Join - http://www.roblox.com/My/Groups.aspx?gid=468509
|
|
|
| Report Abuse |
|
|
|
| 07 Feb 2015 09:41 PM |
| Thanks for the quick and helpful answer |
|
|
| Report Abuse |
|
|