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

Trying to use UIS to detect a key down but just getting "Keycode is not a valid member of Input"?

Hi, I'm trying to use UserInputService to detect when the left shift key is pressed and released. I wrote this following some tutorials I found but whenever I try and use it I just get "Keycode is not a valid member of ImputObject." I don't know what I'm doing wrong and when I look for other tutorials it's just the same as what I'm already doing. This is inside a LocalScript within StarterPlayerScripts. I tried it in StarterCharacterScripts as well but it didn't make a difference.

local UIS = game:GetService("UserInputService")

UIS.InputBegan:Connect(function(input)
	if input.Keycode == Enum.KeyCode.LeftShift then
		print("Shift pressed")
	end
end)
	
UIS.InputEnded:Connect(function(input)
	if input.Keycode == Enum.KeyCode.LeftShift then
		print("Shift released")
	end
end)

2 comments

0

It's supposed to be KeyCode, not Keycode.

0

tysm I can't believe I missed that :/

1 answer

As LoveSpeaksOutTruth commented, I typed "Keycode" instead of "KeyCode".

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