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

How to unbind/bind specific keys?

Asked by 5 years ago
Edited 5 years ago

I want to know how to unbind the arrow keys (up, down, left, right) specifically, not the WASD keys or any other unspecified keys. I'm assuming you have to use ContextActionService, but I couldn't figure out how it could be done from the dev wiki.

I tried to use:

ContextActionService:UnbindAction()

But it was not clear what I was supposed to put as the parameter, besides a string referred to as "actionName".

Secondly, when the binds are finally cleared so pressing the arrow keys don't move the camera or the player (these are bad controls anyway), how would I assign a custom bind/function?

0
the parameter of :UnbindAction() is the action name, if you'd want to see the binds just go to the developer console and click binds and the names of them User#23365 30 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

ContextActionService:BindAction() holds four parameters. The first parameter referred to "actionName" by ROBLOX, really means the referenceName, meaning whenever you'd like to work with a certain Instance controlled or created by this Service, you provide them referenceName you gave it. The second argument is a function, I believe this is what you're looking for? The function has to be written separately from the BindAction() call, then called without parentheses. The third and fourth are simple. If you want to have it functional (Boolean), and the KeyInput that would fire from the use of a Computer. (This is a tuple, this allows you to provide as many KeyInput arguments you'd like.)

local function myfunc ()
    print("Hello!")
end
ContextActionService:BindAction("variable", myfunc, true, "Q")

I'm not entirely sure this is what you're looking for, but I hope it helps anyway. If so don't forget to accept and upvote Good luck!

Ad

Answer this question