Gamepad behaves unexpectedly when connecting a function to UserInputService (InputBegan, InputEnded, InputChanged)

I have connected a function to three UserInputService events (InputBegan, InputEnded, and InputChanged), in a such manner:

UIS.InputBegan:Connect(function(inp, gp) IM.InputBegan(inp, gp) // I do some calculations here end)

The issue is that when this part of the code is present, gamepad/xbox controls seems to behave in an undefined manner, as the jump button sometimes works and sometimes doesn’t, and the thumbstick works in a laggy-like fashion.

I was wondering why this happens and what possibilities exist to solve it?
Thanks a lot

The ButtonA problem might be related to this:
https://devforum.roblox.com/t/contextactionservice-doesnt-fire-consistently-for-playeractions-characterjump-when-buttona-is-used/179224

So that part of the problem might be a bug with user input in the engine. EDIT: I think the gameProcessedEvent parameter might not be correct for ButtonA actions, try ignoring it for ButtonA and see what happens.

I’m not sure about the “thumbstick working in a laggy-like fashion”, any chance you can add a gif/code showing this?

Just checked it out, although I’m using UserInputService instead of ContextActionService, that might have something to do with this issue, time to wait for a solution/fix then :slightly_smiling_face:

Also this is me moving the thumbstick in the upwards direction (holding the direction at least during intervals of 1 second)

https://gfycat.com/SardonicSplendidFishingcat

1 Like

Is this similar to your code?

--on input began
if gpe then return end
--if thumbstick
resetmovement()

--on input changed
if gpe then return end
--if thumbstick
setmovement(input)

--on input ended
--if thumbstick
resetmovement()

--no modification to movement in later code

Also how are you moving the character?

My code does contain if gpe then return end but it doesn’t mess with character movement at all. The character should only move due to roblox core code.

Have you checked to make sure it does not yield and that it runs fairly quickly?

1 Like

It should run failry quickly, but I even put all the function’s code in a coroutine and it still bugs out

1 Like