Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
corbenv 17
4 years ago

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)
0
It's supposed to be KeyCode, not Keycode. AntiWorldliness 868 — 4y
0
tysm I can't believe I missed that :/ corbenv 17 — 4y

1 answer

Log in to vote
0
Answered by
corbenv 17
4 years ago

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

Ad

Answer this question