I want to script a run toggle into my game. So far, all of the controls I have scripted in have a keybind on every platform; however, I’m having trouble thinking of what would be a good keybind for the toggle on Xbox. I looked at the KeyCode list on the API Reference and noticed that it says Thumbstick1 and Thumbstick2. I’m not sure if those are for clicking the thumbsticks or just moving them. I don’t have an Xbox, and I don’t know anyone with one so I can’t figure it out on my own. ;/
This may be a useful page to you.
I believe if you are simply using Enum.Keycode.Thumbstick1 then it counts as pressing, but if you use it combined with UserInputState you can get its direction:
UserInputService.InputChanged:Connect(function(input, processed)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
print(input.Position.X, input.Position.Y)
end
end
end)
Unfortunately I haven’t tested any of this as I’m unable to right now, but I believe this should help you aim in the right direction.
Also, Enum.Keycode.Thumbstick1 / 2 might also be triggered by moving as well as pressing, if that is indeed the case you can just check if the direction is 0 and that should mean it is being pressed down instead.
Just a word of advice, it may be more intuitive to double press forward on the thumbstick to toggle a sprint as its much easier than pressing down, and also a lot of games do that.
I am pretty sure that clicking the analogue sticks / pressing the thumbsticks are ButtonL3
for the left analogue and ButtonR3
for the right counterpart
They are! Thank you! I completely overlooked that…
I never knew that! I always wondered what those were for. I thought they were for some special controllers that might have more buttons or something, like those elite XBOX controllers with the levers underneath
Also of note, ButtonR3 will always have processed as true so don’t trust it. The only way around this is to manually track if they are in a ui menu or not. Same deal with ButtonA!