I’m trying to get a signal to fire whenever the E key or the X button on a gamepad is pressed but it only seems to function when the E key is pressed. I tested it on studio and on an xbox one, still the same issue.
local UIS = game:GetService("UserInputService")
local keyE = Enum.KeyCode.E
local buttonX = Enum.KeyCode.ButtonX
local function WasItInteract()
return UIS:IsKeyDown(keyE) or UIS:IsKeyDown(buttonX)
end
UIS.InputBegan:Connect(function(input)
if WasItInteract() then
print("Interact pressed")
end
end)
What if you sent the input.KeyCode then you compare both of them
local UIS = game:GetService("UserInputService")
local keyE = Enum.KeyCode.E
local buttonX = Enum.KeyCode.ButtonX
local function WasItInteract(key)
return key == keyE or key == buttonX
end
UIS.InputBegan:Connect(function(input)
if WasItInteract(input.KeyCode) then
print("Interact pressed")
end
end)