So I'm upgrading my scripts from UserInputService to ContextActionService (so that my binded keys don't fire when you type in chat) and I'm wondering how I can set multiple keys to a single binding. For example, I currently have this:
function movement(name,state) if state == Enum.UserInputState.Begin then game.ReplicatedStorage.ChangeKeys:FireServer(name,true) elseif state == Enum.UserInputState.End then game.ReplicatedStorage.ChangeKeys:FireServer(name,false) end end cas:BindAction("up",movement,false,Enum.KeyCode.W) cas:BindAction("left",movement,false,Enum.KeyCode.A) cas:BindAction("down",movement,false,Enum.KeyCode.S) cas:BindAction("right",movement,false,Enum.KeyCode.D)
How could I set it so that something such as
cas:BindAction("up",movement,false,Enum.KeyCode.W)
would be binded to both the "W" key and the "Up" arrow? All help is appreciated. Thanks!
All you have to do is add more arguments to the end. For instance:
cas:BindAction("up",movement,false,Enum.KeyCode.W,Enum.KeyCode.Up)
The code above would make it so your action would fire for both W and Up.
If this helped, please Accept my answer. If it didn't, please tell me and I will try to help you as much as I can.