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
 

Is it possible to stop specific keys from working?

Previous Thread :: Next Thread 
jbjgang2 is not online. jbjgang2
Joined: 07 Feb 2010
Total Posts: 8948
25 Aug 2014 04:11 PM
Im making a 2D game and I do not want the player to be able to use the W and S keys. how can this be done?

Swaggin' since 2010
Report Abuse
xXxBOiL3DxXx is not online. xXxBOiL3DxXx
Joined: 08 Sep 2012
Total Posts: 110
25 Aug 2014 05:22 PM
just put invisible walls on the sides. That way, W and S won't do anything.
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Aug 2014 05:28 PM
If you don't want to put invisible walls, you could do something like this in a local script:

plr = game.Players.LocalPlayer
m = plr:GetMouse()

for i, v in pairs(game:service("ControllerService"):GetChildren()) do
if v.ClassName == "HumanoidController" then
v.Parent = game.Lighting
end
end

m.KeyDown:connect(function(k)
if k == "d" then
plr.Character.Humanoid:MoveTo(plr.Character.Torso.Position + Vector3.new(.1, 0, 0)
elseif k == "a" then
plr.Character.Humanoid:MoveTo(plr.Character.Torso.Position + Vector3.new(-.1, 0, 0)
end
end)
Report Abuse
Kodran is not online. Kodran
Joined: 15 Aug 2013
Total Posts: 5330
25 Aug 2014 05:31 PM
Forgot some close brackets and you might need to up the amount they move. That's just a framework to build off of, you'll need to make it so when they press the key it loops that and if they stop pressing the key it stops the loop so you don't have to keep continuously hitting the key.
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