Problems with Enum.Keycode

When I use the brackets with the Enum.Userinput, it keeps showing error < is not a valid member of “Enum.KeyCode”

My script here is:

local user = game:GetService('UserInputService')
user.InputBegan:Connect(function(key, the)
	for i,v in ipairs(script.Parent.Text:split("")) do	
		print(string.upper(v))
		print(Enum.KeyCode[string.upper(v)])
		if key.KeyCode == Enum.KeyCode[string.upper(v)] then
			script.Parent.Text = '<b>'..i..'</b>'
		end
	end
end)

My error:
< is not a valid member of “Enum.KeyCode”

The reason you get that error is because the actual key “<”, is not registered as that symbol in the keycode API,

All of the keycodes go off specific names. Having something like Enum.KeyCode.< would not be logical as well, it would think that your trying to use the less than symbol.

1 Like

I know, im pressing specific keys like H or E, now I dont know why H and E are being read as < or >

Hm, weird, maybe it’s something to do with keyboard layouts? Perhaps you could try checking if the input is an actual KeyCode?

oh wait, im relying on the text on the textlabel, if i change the text on the textlabel, it will change the script, so i found the problem lol

Ah yeah, no problem, best of luck with your project!