I wanna get Gamepad Thumbstick coordinate

i wanna get Thumbstick changed with their coordinate.

for example, if we press “E” then we can play function with UserInputService.InputBegan and we can get we pressed “E”.
but i cannot use UserInputService.InputBegan for joystick so i used UserInputService.InputChanged.

so this prints how much changed.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputChanged:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Thumbstick2 then
		print(math.round(Input.Delta.X*100)/100, math.round(Input.Delta.Y*100)/100, math.round(Input.Delta.Z*100)/100)
	end
end)

It prints 0.5 when tilted to the right by 0.5, prints -0.5 when standing up.

I decided to calculate this to get the coordinates.

local UserInputService = game:GetService("UserInputService")

local X, Y = 0, 0

UserInputService.InputChanged:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Thumbstick2 then
		X += Input.Delta.X
		Y += Input.Delta.Y
		print(math.round(X*100)/100, math.round(Y*100)/100)
	end
end)

However, this script is not perfect and will deviate from the correct values ​​over time.

I want a script that prints 0 when the thumbstick is standing up and 1 when it is fully tilted.

1 Like

Thank @NobleReign for giving good example.
And I apologize to all of you for asking a question without doing more research.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputChanged:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Thumbstick2 then
		print(math.round(Input.Position.X*100)/100, math.round(Input.Position.Y*100)/100, math.round(Input.Position.Z*100)/100)
	end
end)

The solution was to just use Position instead of Delta.
Thx again, Noble.

1 Like