Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I detect Thumbstick Positions?

Asked by 5 years ago

I'm attempting to create a "leaning" animation for players when they are turning a vehicle in my racing game, however I don't know how to detect when someone pushes left or right on the thumb-stick.

local userInputService = game:GetService("UserInputService")

local runService = game:GetService("RunService")

-- Make variables for player, character, and camera

local player = game.Players.LocalPlayer

while not player.Character do wait() end

local character = player.Character

local LTurn = character.Humanoid:LoadAnimation(script.Parent.TurnLeft)

if input.UserInputType == Enum.UserInputType.Gamepad1 then

if input.KeyCode == Enum.KeyCode.Thumbstick1 then

if (Vector3.new(input.Position.X, 1), true) and character.Humanoid.Sit == true then

LTurn:Stop()

**if input.UserInputType == Enum.UserInputType.Gamepad1 then if input.KeyCode == Enum.KeyCode.Thumbstick1 then

-- If Left Stick's Position is -1 is pressed then make the character lean Left if (input.Position.X < 0) and character.Humanoid.Sit == true then LTurn:Play()**

end

end

end)

Answer this question