How to know when the joystick "thumbstick2" is in use? [XBOX]

Hi guys, I want to add xbox control’s in my Over-The-Shoulder’s module.

Currently I am using UserInputService.InputChanged to know when Thumbstick2’s position update.
But I need to know when the joystick is in use too like when a key is pressed to be able continue the tweening camera .

I’ve been trying to use UserInputService.InputBegan but it does not detects the movements of the joystick “Thumbstick2”. It’s logic.

I thought to use ContextActionService but I’ve had the impression this service is the same thing has UserInputService.InputBegan but with bind methods so it can’t help me with my problem.

Does someone have any solutions to find or detect when the thumbstick2 is being used?

local UserInputService = game:GetService("UserInputService")

return function()
	local thumbstickDelta =
	local thumbstickMovedConnection

	return {
		Enable = function()
			thumbstickMovedConnection = UserInputService.InputChanged:Connect(function(inputObject, gameProcessedEvent)
				if (inputObject.KeyCode == Enum.KeyCode.Thumbstick2) then
					local Position = inputObject.Position
					thumbstickDelta = (, -(Position.Y)) * 10)
		Disable = function()
		GetDelta = function()
			local temp = thumbstickDelta
			thumbstickDelta =, 0)
			return temp
1 Like

At a glance this seems fine. Just to be sure, you are calling your Enable function, correct?

Also, just as an aside the InputObject returned by InputChanged gives you a InputObject | Roblox Creator Documentation value, no need to calculate that on your own (unless you need to).

You need to think of the thumbstick as always in use. You as a developer have to decide what input is meaningful and what is not.

The easiest way to tackle this problem is to implement dead-zones. When the magnitude of an input is greater than some defined threshold, you can infer that the thumbstick is “in-use.” You can digitize this analogue input by calling logic when that threshold is crossed; input begins when the threshold is exceeded, and the input stops once the magnitude falls back within the threshold. This is also just practical in general, since many controllers do not return to a perfect “0,0” position when upright.

For reference, the default ROBLOX control scripts appear to use a dead-zone threshold of 0.2 for movement and 0.1 for camera controls (in reference to input being mapped as a unit vector), if I’m interpreting these scripts correctly. Personally, I find that 0.1 is too low, and I often get camera drift as a result when using my controller.

1 Like

The module work but when the joystick stop to move on the gamepad the camera stop to move even if the joystick is pushed.

I’m really dumb lol, I had checked the input values and I believed to conclude that the delta remained frozen at the position after having released the joystick but after rechecking apparently not. But what you mean about “dead-zone threshold”? I am not very familiar with controller systems and I am not very familiar with controller systems and related terms.

Basically, once you have retrieved your thumbstick position, you get the magnitude of that position relative to the origin. ROBLOX maps their thumbstick inputs to points that are clamped within the unit circle, meaning your thumbstick can only ever be as far as “1” away from straight up in any direction.

If you decide that “0.2” is how far away from straight up you want to start considering input, then any position with a magnitude greater than that can be interpreted as in-use, and anything with a magnitude of less than that as the thumbstick not being interacted with. “0.2” would be your deadzone threshold.

1 Like