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

How can I assign buttons from an Xbox controller to specific actions?

Asked by 3 years ago
Edited 3 years ago

Here is the code I've been working off of. I've gotten the Controller to work, but for reasons unknown to me the function I want to assign to the A button works with every button other than A and left/right on the D-Pad

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(inputObject, gameProcessedEvent)
    if gameProcessedEvent then return end
    if inputObject.KeyCode == Enum.KeyCode.Space or Enum.KeyCode.ButtonA then

--function

    end
end)

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
3 years ago

You need to tell the script what it needs to compare with Enum.KeyCode.ButtonA:

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(inputObject, gameProcessedEvent)
    if gameProcessedEvent then return end
    if inputObject.KeyCode == Enum.KeyCode.Space or inputObject.KeyCode == Enum.KeyCode.ButtonA then

(function)

    end
end)
0
Hmm, now it completely ignores the controller.. Any other suggestions? antazma 8 — 3y
0
I think I found the issue. I'm trying to assign the function to the same button that jump is automatically set to.. antazma 8 — 3y
Ad

Answer this question