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

How do i make combos with UserInputService ?

Asked by 5 years ago

How would i make it so when the player press E and R it print "E and R was pressed!"

local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(K)
    if K.KeyCode == Enum.KeyCode.E and Enum.KeyCode.R then
            print("E and R was pressed !")
        end
end)

1 answer

Log in to vote
3
Answered by 5 years ago

There are two ways to do this. One keep track of key presses and second use GetKeysPressed or just check each key using IsKeyDown

As you only have two keys I would use IsKeyDown.

Example:-

local userInpServ = game:GetService('UserInputService')

userInpServ.InputBegan:Connect(function(inpObj)
    if userInpServ:IsKeyDown(Enum.KeyCode.E) and userInpServ:IsKeyDown(Enum.KeyCode.R) then
        print('E and R pressed')
    end
end)

I hope this helps.

0
Thanks ! xJathur95x 129 — 5y
Ad

Answer this question