When a player holds a button down and presses another button

I am adding controller support to my game and one of the controls I want players to hold down buttonR1 and press ButtonA while buttonR1 is being held down.

if UserInputService:IsKeyDown(Enum.KeyCode.ButtonR1) then
		if inputObject.KeyCode == Enum.KeyCode.ButtonA then
print("Button pressed")
end

this is what I have so far and it doesn’t work because it pretty sure the game is checking if a is being pressed as soon as buttonR1 is being held down, however I don’t know how to do it correctly.

Is there anything going on in output showing any errors?

no there are no errors it just doesn’t work

I assume this code is in the local script. Here’s what I wrote. Hope it helps:

I don’t exactly know what ButtonR1 is, so heres a simple example.

local uis = game:GetService("UserInputService")
uis.InputBegan:Connect(function(input, processed)
     if uis:IsKeyDown(Enum.KeyCode.somekeycodehere) and uis:IsKeyDown(Enum.KeyCode.anotherkeycodehere) then 
          -- your code here. code written here will be executed after the key combination is pressed
     end
end)
1 Like