In short
Enums are Roblox's fixed lists of options: Enum.KeyCode, Enum.Material, Enum.EasingStyle and many more. This error means the name after the dot is not in that list. Shift is not a valid member of "Enum.KeyCode" happens because the keys are LeftShift and RightShift. Type the enum in the Script Editor and pick the item from the list it shows, so the name is always one that exists. If the message ends in "Enum" only, the enum type itself is misspelt.
What the message means
Players.Player1.PlayerScripts.Sprint:4: Shift is not a valid member of "Enum.KeyCode"
Other forms of the same message:
Glowing is not a valid member of "Enum.Material"Smooth is not a valid member of "Enum.EasingStyle"Keycode is not a valid member of "Enum"
Enum names are case sensitive: Enum.Keycode fails, Enum.KeyCode works.
The line in the message points straight at the bad name, so this error is quick to fix once you know the right one.
Causes and fixes
Two things cause this error in practice. Each one below has the smallest code that triggers it, then the fix.
The item has a different name
Common guesses that do not exist: KeyCode.Shift (LeftShift), KeyCode.Ctrl (LeftControl), Material.Glowing (Neon), EasingStyle.Smooth (Sine or Quad).
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input, processed)
-- Shift is not a valid member of "Enum.KeyCode"
if input.KeyCode == Enum.KeyCode.Shift then
print("sprint")
end
end)
Use the real item name. For Shift, check both sides of the keyboard.
local UserInputService = game:GetService("UserInputService")
UserInputService.InputBegan:Connect(function(input: InputObject, processed: boolean)
if processed then
return
end
if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
print("sprint")
end
end)
The Enum type itself is misspelt
When the type is wrong, the message ends in "Enum": Keycode is not a valid member of "Enum".
local part = workspace:WaitForChild("Lava")
-- Materials is not a valid member of "Enum"
part.Material = Enum.Materials.Neon
Fix the type name. Most enum types are named like the property that uses them: Material, KeyCode, EasingStyle, PartType.
local part = workspace:WaitForChild("Lava") :: BasePart
part.Material = Enum.Material.Neon
Fix it in your place
Paste the error, RoCode fixes it in your place
Copy the line from Output and paste it here. RoCode opens the script it names in the place you have open in Studio, works out which of the causes above it is, and edits the code there instead of handing you a snippet to paste.
RoCode is an AI agent for Roblox Studio: it reads the scripts in the place you have open, finds the line and edits it there, and every change is an undo point. It runs on Windows or macOS with a desktop browser. Free to start, with free credits every day.
How to find the line that causes it
- Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
- Find the first red line. It starts with the script's place in the Explorer and the line number, such as
ServerScriptService.Shop:12:. - Click the red line. Studio opens that script with the cursor on the failing line.
- Read the lines between
Stack BeginandStack Endunder it: they list the calls that led there, newest first, so you can see which function called the broken one. - Still not sure which value is wrong? Add
print(typeof(x), x)just above the line, or set a breakpoint on it and read the values in the Watch window.
Questions
How do I see every item of an Enum?
Type Enum.KeyCode. in the Script Editor and it lists them, or open the enum on the Roblox Creator Docs enums page. In code, Enum.KeyCode:GetEnumItems() returns them all.
What is the KeyCode for Shift, Ctrl and Alt?
LeftShift and RightShift, LeftControl and RightControl, LeftAlt and RightAlt.
Can I use a string instead of the Enum item?
For many properties yes, such as part.Material = "Neon", but a misspelt string fails too, with a different message. The Enum item is safer because the editor completes it.
Can RoCode fix it?
Yes. Paste the Output line into RoCode. It replaces the name with the Enum item that exists in your open place.
Sources and further reading
How the code was checked: every block marked Fixed passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 12 November 2026), and every block marked Breaks compiles and fails only when it runs. The message wording was checked against the message format strings in Roblox Studio itself (macOS build installed on 12 November 2026) on 12 November 2026. A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.