Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to disable certain Controls?

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.

1 comment

0

Ended up figuring it out while messing around with the ControlScript in the PlayerScripts :)

1 answer

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

2 comments

0

I forgot the connection line mouse.KeyDown:connect(onKeyDown) on the second one

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

This discussion is preserved as it was. New answers, comments, and votes are closed.