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

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

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

✓ Accepted answer

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)

2 comments

0

Hmm, now it completely ignores the controller.. Any other suggestions?

0

I think I found the issue. I'm trying to assign the function to the same button that jump is automatically set to..

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