Why does left shift not work in UserInputService

I am trying to make a shift to sprint script in my game and when I type my script, it doesn’t work. It doesn’t show the print statement and it doesn’t show any errors when I press shift. This makes no sense because I did a shift to sprint script before and it didn’t get buggy like this. My code is being shown below and help is appreciated and thank you in advance.

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer

UIS.InputBegan:Connect(function(input, isTyping)
	if isTyping then return end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		print("Left shift was pressed by " .. plr.Name)
	end
end)
1 Like

For your information, if the script isn’t a LocalScript, it won’t work(UserInputService depends on client). If the script is incorrectly parented, it will not work either. It could be either issues.

1 Like

i think left shift is an input type, not keycode. but I’m not sure, only thing i can think of

Works fine for me when I inputted your code into local script into StarterGui.

This can happen if you have mouse lock enabled or bound to the left shift key. PlayerModule is greedy for the keys bound to mouse lock. After it toggles the mouse lock it will sink any subsequent input to the key. Here’s what happens when I turn shift lock off and run your exact same code:

@ThisAmAlt If you’re unsure, you can always check before posting to give more accurate advice. :slight_smile:

5 Likes

Ohhhhh i do have shift lock on so when i get home i will turn it off and see if my code works thank you