Hello everyone! I was wondering if their was an easier way to make mobile inputs. The reason why is because I realize that with ContextActionService, and me binding an action, when im on pc, pressing e wouldn’t do what it did before because e is set to something else.
local context = game:GetService("ContextActionService")
local function onButtonPress(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
print("Activates this instead of all my other events set to e")
end
end
local mobilerunbutton = context:BindAction("EMove",onButtonPress,true,Enum.KeyCode.E)
context:SetPosition("EMove",UDim2.new(0.65,0,0.2,0))
local EMove = context:GetButton("EMove")
EMove.Size = UDim2.new(0.15, 0, 0.15, 0)
Up their you can see that it only prints what’s in their and not any of my other code. In theory I can just put all my codes in this event, but that’s far to much code to convert and I am wondering if theirs an easier way to simulate the press of any button through mobile instead of replacing it, unless I’m doing something wrong.
I’m a little confused by what you are asking. Do you want a way to create custom mobile buttons or use ContextActionService to create mobile buttons? I’ll admit I’m unfamiliar with context action service, so I don’t understand what your code is attempting to do. I’m a fast learner though, so I should be able to help if you tell me what is is you explicitly want.
After learning about ContextActionService, what you are asking doesn’t make sense. If you bind something it can create mobile buttons by using a built-in service. That’s a pretty easy to make unless you want something more customizable.
However, if you are asking why it fires the binded action before the rest of your code then it makes sense since it’s a core script. The thing is, you shouldn’t have any other code that is meant to accomplish the same thing if you’re planning on using ContextActionService, as that would be redundant as well as bad coding practice.
The only other thing I could think of for what you are asking is if there is a way to use ContextActionService to accomplish the same actions as you previously could using some other unknown method. If this is what you are asking then it depends on your code. If it’s combined into a single function then it should be relatively easy to call those function through ContextActionService.