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)
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:
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.
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.
-- 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)
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.
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.