Gamepad Thumbstick

Hello I’m trying to make a block that moves using Gamepad thumbstick, but I don’t know how to know how to get the thumbstick position, I saw on forum I have to see Delta.X but it didn’t work. Here the code

Code

if input.KeyCode == Enum.KeyCode.Thumbstick1 and player.PlayerGui:FindFirstChild("TowerCraneControls") then
		print(input.Delta.X)
		if  input.Delta.X < 0 then
				Action:FireServer("TurnL")
			else
				Action:FireServer("StopTurn")
			end
	end

This is how you can get the gamepad thumbstick position

local userInputService = game:GetService("UserInputService")

userInputService.InputChanged:Connect(function(input, processed)
	if input.UserInputType ~= Enum.UserInputType.Gamepad1 then return end
	if input.KeyCode == Enum.KeyCode.Thumbstick1 then
		print("Thumbstick1", input.Position)
	elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
		print("Thumbstick2", input.Position)
	end
end)

okay but this code gives me the position, if I want to know if the Thumbstick is on the right or left ?

local userInputService = game:GetService("UserInputService")

userInputService.InputChanged:Connect(function(input, processed)
	if input.UserInputType ~= Enum.UserInputType.Gamepad1 then return end
	if input.KeyCode ~= Enum.KeyCode.Thumbstick1 then return end
	if input.Position.X < -0.5 then print("Left") end
	if input.Position.X > 0.5 then print("Right") end
end)
4 Likes

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