My thumbsticks aren't detecting for controller

Issue I’m running into is when I use my left thumbstick to move it doesn’t detect for some reason. I don’t want it to detect when the thumbstick is being pushed down but only what the stick has been touched/moved.

Heres the code (the print only detects the keyboard keys not the thumbstick):

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isWKeyDown = true
		if not isRunning then
			startRunning()
			print("Thumbstick1 detected.")
		end
	elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isAKeyDown = true
		if not isRunning then
			startRunning()
			print("Thumbstick1 detected.")
		end
	elseif input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isSKeyDown = true
		if not isRunning then
			startRunning()
			print("Thumbstick1 detected.")
		end
	elseif input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isDKeyDown = true
		if not isRunning then
			startRunning()
			print("Thumbstick1 detected.")
		end
	elseif input.KeyCode == Enum.KeyCode.LeftControl then
		LeftControlDown = true
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isWKeyDown = false
		if not (isAKeyDown or isSKeyDown or isDKeyDown) then
			stopRunning()
			print("Thumbstick1 stopped detecting.")
		end
	elseif input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isAKeyDown = false
		if not (isWKeyDown or isSKeyDown or isDKeyDown) then
			stopRunning()
			print("Thumbstick1 stopped detecting.")
		end
	elseif input.KeyCode == Enum.KeyCode.S or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isSKeyDown = false
		if not (isWKeyDown or isAKeyDown or isDKeyDown) then
			stopRunning()
			print("Thumbstick1 stopped detecting.")
		end
	elseif input.KeyCode == Enum.KeyCode.D or input.KeyCode == Enum.KeyCode.Thumbstick1 then
		isDKeyDown = false
		if not (isWKeyDown or isAKeyDown or isSKeyDown) then
			stopRunning()
			print("Thumbstick1 stopped detecting.")
		end
	elseif input.KeyCode == Enum.KeyCode.LeftControl then
		LeftControlDown = false
		ToggleAnimationAndSound(true)
	end

	ToggleRunningIfAirborne()
end)
3 Likes

lol it doesn’t work because the code isn’t set up to detect thumbstick, only keyboard input, Matey. You need to put UserInputService and not KeyCode. Lemme show you how it’s done

UIS.InputBegan:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.W then
            isWKeyDown = true
            if not isRunning then
                startRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.A then
            isAKeyDown = true
            if not isRunning then
                startRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.S then
            isSKeyDown = true
            if not isRunning then
                startRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.D then
            isDKeyDown = true
            if not isRunning then
                startRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.LeftControl then
            LeftControlDown = true
        end
    elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
        if input.KeyCode == Enum.KeyCode.Thumbstick1 then
            if not isRunning then
                startRunning()
                print("Thumbstick1 detected.")
            end
        end
    end
end)

UIS.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.Keyboard then
        if input.KeyCode == Enum.KeyCode.W then
            isWKeyDown = false
            if not (isAKeyDown or isSKeyDown or isDKeyDown) then
                stopRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.A then
            isAKeyDown = false
            if not (isWKeyDown or isSKeyDown or isDKeyDown) then
                stopRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.S then
            isSKeyDown = false
            if not (isWKeyDown or isAKeyDown or isDKeyDown) then
                stopRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.D then
            isDKeyDown = false
            if not (isWKeyDown or isAKeyDown or isSKeyDown) then
                stopRunning()
            end
        elseif input.KeyCode == Enum.KeyCode.LeftControl then
            LeftControlDown = false
            ToggleAnimationAndSound(true)
        end
    elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
        if input.KeyCode == Enum.KeyCode.Thumbstick1 then
            if not (isWKeyDown or isAKeyDown or isSKeyDown or isDKeyDown) then
                stopRunning()
                print("Thumbstick1 stopped detecting.")
            end
        end
    end

    ToggleRunningIfAirborne()
end)

I am also encountering a similar issue! I have a very generic chunk of code that should fire whenever any input is given (regardless of keyboard or GamePad), which it does for every single possible input besides Thumbstick movement (Thumbstick clicking is recognized). I believe this to be a glitch on Roblox’s part that requires resolution. Here’s my code:

UIS.InputBegan:Connect(function(input)
    print(input.KeyCode)
end)

This is incorrect and I highly recommend testing your code before coming off so certain. “Lemme show you how it’s done” only to follow up with an incorrect/unhelpful solution is disappointing for those looking for real feedback.

Yeah man, I still haven’t figured it out, the right stick works but the left stick doesn’t work.

You got the right stick to work? For me it’s neither. I’ll go check again.

I wrote a custom camera script, I can use the right stick to look around with it. I also have a run script but I have to press L3 for the sprint to work even though its all momentum based, I tried to input it using the left stick but didn’t work.

How do you capture the right stick’s movements? UserInputService?

Yes indeed

script:

-- controller support
Input.InputChanged:Connect(function(InputObject, gameProcessedEvent)
	if gameProcessedEvent then return end
	if InputObject.KeyCode == Enum.KeyCode.Thumbstick2 then
		
		local StickMovement = InputObject.Position
		local Delta = Vector2.new(StickMovement.x / Sensitivity, StickMovement.y / Sensitivity) * Smoothness
		local X = TargetAngleX + Delta.y

		TargetAngleX = math.clamp(X, -80, 80) -- look up and down
		TargetAngleY = (TargetAngleY - Delta.x) % 360 -- look left and right
	end
end)

And if you sub Thumbstick1 for Thumbstick2 in that code it does nothing?

Haven’t tried it yet, I don’t have a controller near me.

So it appears that the only way to record changes for Thumbstick controls is by using InputChanged (instead of InputBegan or InputEnded like I would expect). It appears to work for both Thumbstick1 and Thumbstick2. I don’t know if this is intentional by Roblox, but I would say it is highly confusing if nothing else and should be clarified in the documentation guide for Gamepad Inputs:

I’m just glad to have an answer on this because it has been bugging me for months.

2 Likes

inputchanged, imo, is kind of finicky for me tbh, it doesn’t work well with my running script, I would have to rewrite it just for it to work with controller.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.