✓ Accepted answer
It is pretty simple, you can convert your KeyCode to a string and save it inside a value.
You simply use the tostring() method that Lua has to convert the input to an actual string which you can input into a string value or a table.
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
if(input.KeyCode == Enum.KeyCode.E) then
game.Workspace.ExampleStringValue.Value = tostring(input.KeyCode);
end;
end);
This is the simple example to capture the input that you desire and save it as a string to a value.
You can check for the UserInputType in UserInputService to make sure to capture specific inputs such as the keyboard or mouse for example.
Here's a list with all the possible User Input types that you can check for: https://developer.roblox.com/en-us/api-reference/enum/UserInputType
An example on how to check first for User Input Type and then check for the KeyCode:
game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
if (input.UserInputType == Enum.UserInputType.Keyboard) then
if(input.KeyCode == Enum.KeyCode.E) then
game.Workspace.ExampleStringValue.Value = tostring(input.KeyCode);
end;
end;
if(input.KeyCode == Enum.KeyCode.E) then
game.Workspace.ExampleStringValue.Value = tostring(input.KeyCode);
end;
end);
This is all you need to know as for you to resolve your issue, although I would recommend you to use ContextActionService which is another way of capturing input of the player, in my opinion it is a better way than catching it through UserInputService because you can modularize your input from the beginning for various types of controls such as an XBoX Controller or a Touchpad.
Here is a link to the API explaining in detail about it:
https://developer.roblox.com/en-us/api-reference/class/ContextActionService
If you have any more questions make sure to ask them. Good luck!