✓ Accepted answer
It's always good practice to use Enums
Part.Material = Enum.Material.Glass
Part.Shape = Enum.PartType.Ball
but it's also possible to use strings, although not recommended (typos and other stuff that will make you cry)
Part.Material = "Glass"
Part.Shape = "Ball"
but the least intuitive of them all are numbers, you can use numbers as well.
Part.Material = 1568
Part.Shape = 0
Why do numbers work? Isn't it odd that we can set properties that are enums, using numbers? It seems like we're pulling numbers out of thin air but actually, these numbers and enums are closely related.
Introducing EnumItem.Value
EnumItems actually have a property called Value which corresponds to that EnumItem's Id. The same goes for KeyCode, KeyCodes have Values as well.
So in order to put KeyCodes into NumberValues, what we can do is not store the KeyCode but rather the Value of the KeyCode
local NumberValue = Instance.new("NumberValue")
NumberValue.Name = "KeyCode"
NumberValue.Parent = script
NumberValue.Changed:Connect(print)
game:GetService("UserInputService").InputBegan:Connect(function(InputObject)
if InputObject.KeyCode then
NumberValue.Value = InputObject.KeyCode.Value
end
end)
2 comments
Do you have any code to tell us what you are trying to do?
You could use GetEnumItems like Enum.KeyCode:GetEnumItems()[numberHere]