User Input Service won't detect multiple inputs

Hello, I’m trying to make a sprint, crouch, and slide type movement to my game. I got the sprinting and crouching working. (sliding i’ll make it be its own thing) but for some reason I can’t sprint and press crouch button at same time because roblox won’t even detect ANY inputs when holding a button already.

Heres the code btw

UIS.InputBegan:Connect(function(input, gpe)
	if gpe then
		return
	end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Humanoid.WalkSpeed = 24
	elseif input.KeyCode == Enum.KeyCode.C then
		Humanoid.HipHeight = -1.5
		Humanoid.WalkSpeed = 10
	end
end)

UIS.InputEnded:Connect(function(input, gpe)
	if gpe then
		return
	end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		Humanoid.WalkSpeed = 16
	elseif input.KeyCode == Enum.KeyCode.C then
		Humanoid.HipHeight = 0
		Humanoid.WalkSpeed = 16
	end
end)

This is crazy if that’s actually the case. You would want to use this to detect multiple simultaneous inputs anyways https://create.roblox.com/docs/reference/engine/classes/UserInputService#GetKeysPressed

It should detect both LeftShift and C inputs even if they are pressed at the same time. Did you confirm that it’s not? Maybe by putting print(input.KeyCode) at the beginning of the function? If it really isn’t detecting both inputs then something might be wrong with your keyboard or something.

Also, not sure what behavior you’re expecting when pressing both, but if you press C before letting go of LeftShift then it will return to a WalkSpeed of 16 when you release LeftShift, although you might expect to stay in the crouching state. If this is your problem, you could solve it by setting the sprint/walk/crouch into the same variable. An input of LeftShift or C would set the mode to Sprinting or Crouching respectively. Letting go of one of these controls would return to the walking state only if the current state matches that key. So that if the player lets go of LeftShift while crouching it won’t stop crouching.

I hope this helped, if you clarify your problem more I could give you more useful assistance.

I just tested your code with print statements rather than adjusting the character and User Input Service does detect when you press multiple keys even if you’re holding down a button already.
Add a print statement under each one and you should see that it’s working, otherwise you do have a major engine bug.
Since you most likely do not have that engine bug then it will have something to do with your code when it is the right keycode.

The gpe isn’t needed for this unless you want to ensure inputs are not processed when the game UI is in focus or someother input is active.

UIS.InputBegan:Connect(function(input)

Is fine for this.

UserInputService.InputBegan’s second parameter:

“Indicates whether the game engine internally observed this input and acted on it”

When concerning keyboard inputs, the second parameter will not be true if your mouse is above a GuiObject. These circumstances are fundamentally unrelated. Left-shift and C are very common keyboard inputs, so when typing in a text field, it is pertinent OP continues to debounce against the second parameter

It’s not needed in this case. I see you’re back to debating everything. If your comment isn’t something to try and help this question - it isn’t needed at all. This is called troubleshooting. Removing what isn’t necessary. Nothing I said was wrong, you’re just being overly petty. Who knows why.

Anywho back the the actual question.
@ ShockingCrafter225
This would let you use the keys as multi keys. May need to change the logic.
That Humanoid.HipHeight = -1.5 dosn’t seem to work for me with r15 body.

UIS.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		--
	end
	if input.KeyCode == Enum.KeyCode.C then
		--
	end
end)

UIS.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift then
		--
	end
	if input.KeyCode == Enum.KeyCode.C then
		--
	end
end)

There is rarely a scenario where the second parameter of UserInputService.InputBegan is irrelevant. This is not one of those scenarios. I am debating you because your advice is harmful to OP’s situation. This is the type of constructive back-and-forth that helps work towards the best solution—my comment is not for nothing