How do you make context action service holdable?

So i was thinking of firing a function continuosly when a player holds the key or the emulator but i only know the basics from alvin blox tutorial . It only fires a function when i press it and release it i wonder how can i change it to hold system so everytime i hold it it will fire the function continously and when i let it go it will stop firing

1 Like

Instead of using contextactionservice ,try using game:GetService(ā€œUserInputServiceā€).InputBegan and game:GetService(ā€œUserInputServiceā€).InputEnded

but i want mobile players to play the game too using the emulator in the context action service

1 Like

hmm, you can create custom buttons for it too and still be able to use UserInputService

1 Like
function customJumpAction(actionName, userInputState, inputObject)
  if userInputState == Enum.UserInputState.Begin then print("Started") end
  if userInputState == Enum.UserInputState.End then print("Ended") end
end

contextActionService:BindAction(
  --[[actionName=]]"customJumpAction",
  --[[functionToBind=]]customJumpAction,
  --[[createTouchButton=]]true,
  --[[inputTypes=]]Enum.PlayerActions.CharacterJump)

This is some code I had lying around, you should be able to detect when a player stops holding a key by making use of the userInputState paramater.

18 Likes