My Input checker is not working, prints wrong things when I press a key?

In this script I am trying to detect if the player is hitting “q” or “e” on their keyboard, and if they are hitting both. The issue i’ve been having is that when you go to check if they have both keys down, a key always shows up with it. Example of this being: When you click q, q appears if you click e e appears, but if you hold q and click e, the e prints with the other full q + e statement, I have tried moving the logic around and adding if not statements but they broke the script and I am at a loss.

screenshot example (Sorry for my bad writing, I use mouse)
Photo of the error, with explanation

Script:

 local UIS = game:GetService("UserInputService")
local character = script.Parent
Keybind1 = Enum.KeyCode.Q
Keybind2 = Enum.KeyCode.E

UIS.InputBegan:Connect(function(input,gameprocessed)
	if input.KeyCode == Keybind1 then
		print("q... ")
	end
		

	if input.KeyCode == Keybind2 then
		print("e...")
	end
			



	if UIS:IsKeyDown(Enum.KeyCode.Q) and UIS:IsKeyDown(Enum.KeyCode.E) then
		print("Q and E are pressed down!")
	end



end)
	
	


Any help is appreciated, this is in starterplayerscripts as well.

Maybe try checking if both keys are pressed down as a first thing in the script, and after that check for individual keys

1 Like

I tried, but it just rearranges the order they come in

have you tried using UIS:IsKeyDown() instead of input.KeyCode?

1 Like
2 Likes