Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make this GamePad script more accurate?

local UserInputService = game:GetService("UserInputService")

function OnInputChanged(Input)
   if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
print (Input.Delta.X, Input.Delta.Y)
        if Input.Delta.X > 0 then
            print("Right")
        elseif Input.Delta.X < 0 then
            print("Left")
		elseif Input.Delta.Y < 0 then
            print("Down")
		elseif Input.Delta.Y > 0 then
            print("Up")
		else
		print "None"
        end
   end
end

UserInputService.InputChanged:Connect(OnInputChanged)

For some reason, this script is printing "Down" even when my thumbstick isn't moving. Other times Its printing "Right" and when I stop moving it says "Left. Also, when I'm going Up it starts printing "Down" when I stop moving. Why is this? How do I make this script more accurate?

1 answer

Im not very good with gamepads, but this ?could work.

local UserInputService = game:GetService("UserInputService")

UserInputService.InputChanged:Connect(function(OnInputChanged)
   if Input.KeyCode == Enum.KeyCode.Thumbstick1 then
	print (Input.Delta.X, Input.Delta.Y)
        if Input.Delta.X > 0 then
            	print("Right")
        elseif Input.Delta.X < 0
            	print("Left")
	else
		print("No X input")
        end
	if Input.Delta.Y > 0 then
            	print("Up")
        elseif Input.Delta.X < 0
           	 print("Down")
	else
		print("No Y input")
        end
   end
end)

2 comments

0

thats literally the same script i posted..

0

not really?

This discussion is preserved as it was. New answers, comments, and votes are closed.