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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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 |
|
|