alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 02 Aug 2014 07:31 PM |
I have a script that lets you move a brick with wasd, but if you try to combine w and d, it only does one.
Heres the code:
mouse.KeyDown:connect(function(key) keydown = false if key == "w" then keydown = true end while keydown do wait() camHold.CFrame = camHold.CFrame*CFrame.new(0,0,-.1) end end)
mouse.KeyUp:connect(function(key) if key == "w" then keydown = false end end)
mouse.KeyDown:connect(function(key) keydown2 = false if key == "s" then keydown2 = true end while keydown2 do wait() camHold.CFrame = camHold.CFrame*CFrame.new(0,0,.1) end end)
mouse.KeyUp:connect(function(key) if key == "s" then keydown2 = false end end)
mouse.KeyDown:connect(function(key) keydown3 = false if key == "d" then keydown3 = true end while keydown3 do wait() camHold.CFrame = camHold.CFrame*CFrame.new(.1,0,0) end end)
mouse.KeyUp:connect(function(key) if key == "d" then keydown3 = false end end)
mouse.KeyDown:connect(function(key) keydown4 = false if key == "a" then keydown4 = true end while keydown4 do wait() camHold.CFrame = camHold.CFrame*CFrame.new(-.1,0,0) end end)
mouse.KeyUp:connect(function(key) if key == "a" then keydown4 = false end end) |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 02 Aug 2014 07:37 PM |
In reference to your last thread: This is why I prefer my method of dealing with key input, much less code duplication.
In reference to this thread: Do other combinations work? |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
| |
|
jerryg225
|
  |
| Joined: 20 Aug 2008 |
| Total Posts: 23187 |
|
|
| 02 Aug 2014 07:40 PM |
| If you want all this code duplication you need to check for both of them before you check for just one of them pushed. Im not reading your code, just a suggestion |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 02 Aug 2014 07:42 PM |
| The code is really short. Most of it repeats. |
|
|
| Report Abuse |
|
|