Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to disable certain Controls?

Asked by 9 years ago

What can I use to disable specific controls a player has such as the arrow keys or W and S? After a lot of research all I could find was an out of date one that disabled all of the controls.

0
Ended up figuring it out while messing around with the ControlScript in the PlayerScripts :) Prohibetur 70 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Though I don't see what situation you would need to remove them. I would just reduce the walkspeed to 0. But if you want to enter something for when W is pressed it would be.

local player = script.Parent.Parent
local mouse = player:GetMouse()
function onKeyDown(key)
if key == "w" then
Instance.new("Sparkles",player.Character.Torso)
mouse.KeyDown:connect(onKeyDown)

if you wanted to make it to where like they couldn't jump you could do

local player = script.Parent.Parent
local mouse = player:GetMouse()
function onKeyDown(key)
if key:byte() == 32 then--32 is the number for spacebar
player.Character:MoveTo(Player.Character.Torso.Position +Vector3.new(0,-2,0))
0
I forgot the connection line mouse.KeyDown:connect(onKeyDown) on the second one GianniKun 40 — 9y
0
Setting the walkspeed to 0 would disable all movement which is not what I was looking for. Thankyou for trying though, I'll just keep looking Prohibetur 70 — 9y
Ad

Answer this question