Is it possible with mobile buttons to deal with keycodes that are being sent so don't need to make a function?

The title explains it.

I am trying to make mobile support for my game and I don’t wanna copy and paste some of my code unless I have to do it. Is it possible to do it without having to make functions inside of localscript?

As far as the question goes, I’m pretty confused. What do you mean by mobile buttons to deal with keycodes? If I’m right in what I think you’re saying, you can use the ContextActionService with the BindAction method, as it takes the following parameters:

1- Name of Action, string - what you want it to be called for debugging purposes
2 - Function, func - The function it’s bound to
3 - Create Touch Button, bool - this is what you’ll want to use as it creates a button for mobile users which when pressed fires the function
4 - Input Type, tuple - All of the input types, i.e. Enum.KeyCode.A

In total, it should look something like this:

CAS:BindAction("Rocket Launch", shootRocket, true, Enum.KeyCode.Q)

I went another way for now. My English is a second language so my apologies.

Right now, I have the code on another script for now, but since BindAction only deals with only functions, I don’t know how to bypass it to do stuff with UserInputService.

Script:

local button1 = cas:BindAction("RunButton", ignore, true, Enum.KeyCode.LeftShift)
local button2 = cas:BindAction("ExecuteButton", ignore, true, Enum.KeyCode.E)
local button3 = cas:BindAction("CrouchButton", ignore, true, Enum.KeyCode.LeftControl)

It really depends on what you’re trying to do, however I do believe nearly everything you can do in the UIS is achievable within the CAS as well. If you currently have InputBegan events then you can just swap them out and it’ll only take roughly around 5 minutes for all of them.

1 Like

Already did it, but thanks lol.