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: Keys problem

Previous Thread :: Next Thread 
alij12 is not online. 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 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
02 Aug 2014 07:37 PM
bmp
Report Abuse
swmaniac is not online. 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 is not online. alij12
Joined: 03 Oct 2011
Total Posts: 1204
02 Aug 2014 07:37 PM
Nope.
Report Abuse
jerryg225 is not online. 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 is not online. 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
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