local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, processed)
if processed then return end
if input.UserInputType == Enum.UserInputType.Keyboard then
-- how to get is letter of alphobet pressed
end
end)
Why are you checking if the length is less than or equal to 1 but also greater than 0? shouldn’t you just use
if #key == 1 then
...
end
Secondly, this won’t work properly at all. Take the “\” key for example (Enum.KeyCode.Backslash). The string for this KeyCode is “\”, which is in fact 1 character, so your check will be true, even though this is not a letter of the alphabet. This check will also be true for all numbers, which is probably not intended.
Here is a function that will work properly:
function check(code)
local num = code.Value
return num >= Enum.KeyCode.A.Value and num <= Enum.KeyCode.Z.Value
end
This function works by comparing the Value of the keycode to the values of A and Z, making sure it is in between the two.