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

How do i make combos with UserInputService ?

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

✓ Accepted answer

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.

1 comment

0

Thanks !

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