Mobile button trigger on release

  1. What do you want to achieve? Hello, i am currently working on a weapon system mobile compatibility, i want to create mobile buttons with the ContextActionService.

  2. What is the issue? The issue is that they trigger when the finger has stopped touching the button.

  3. What solutions have you tried so far? I tried to fix it myself and looked on forums.


There’s a ton of posts about this already, I dont know how you missed them.
Here is a script example fixing your issue:

local ContextActionService = game:GetService("ContextActionService")
-- Setting up the action function
local function action(actionName, inputState, inputObj)
    if inputState ~= Enum.UserInputState.Begin then return end -- Function only runs if the player began holding the button

-- Bind the action to the function
ContextActionService:BindAction("Action", action, true, Enum.KeyCode.T)


It seems to have fixed the issue, thank you, i encounter another issue tho, can i ask you here ?

sure, ask right away, what other problems do you have?

Sorry for late answer, how could i make the camera still move when you hold the button, like for shooting with a gun

Sorry but I can’t help with that, I don’t have that much experience with CAS mobile buttons, but I am guessing that you simply can’t, unless you would make custom button with custom camera handling.

try to use MobileTouch module if im not wrong it should work better because it makes button with a gui instead of contextactionservice

I’m working on a huge rework for it, and i’m not sure if this is a good idea to use it for now as it still is a prototype version which is not really well made and optimized ^^

well im using it in one of my games and it works very well

Yeah it work well, but still not enough in my opinion, it can be a lot better overall !