I am trying to create a minigame which requires users to press random letters on the keyboard, it is all working well when using a concrete letter, although I need to key code to be random.
local UserInputService = game:GetService("UserInputService")
local letterchosen = string.char(math.random(string.byte('A'), string.byte('Z')))
local keycode1 = Enum.KeyCode.letterchosen
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == keycode1 then
step.Text = "1/5"
I am unaware on how to let the code what to press as “keycode1” is obviously not a valid member of Enum, is there any solutions on how to resolve this issue?