I am working on a simple run script, and using UserInputService to detect when the player presses LeftShift.

Code:

local UserInputService = game:GetService("UserInputService")

UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.KeyCode.LeftShift then
		print("the player pressed shift!")
	end
end

But, when I press LeftShift, I don't get anything in the output. So, if you have time, please help me out!

Thanks in advance!

(I put the code in a LocalScript inside of StarterGui)

4 comments

0

Try using this:

0

On line 04, it should be input.KeyCode, not input.UserInputType. Also, I don't think scripts in StarterGui replicate, trying putting it in StarterCharacterScripts.

0

scripts do replicate to the clients in startergui. But radiant is correct that it should be input.Keycode.

0

I did what radiant_Light203 and JustinWel12 said to do and it worked. Thanks!