Roblox Studio error

X is not a valid member of "Enum.Y"

What X is not a valid member of "Enum.Y" means in Roblox Studio, the two things that cause it with the code that triggers each, and the fix for each one.

Updated 12 November 20263 min readErrorLuauWritten by

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.

On this page
  1. What it means
  2. Causes and fixes
  3. Fix it with RoCode
  4. Find the line
  5. Questions
  6. Sources

What the message means

Output (example)
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).

Breaks LocalScript in StarterPlayer.StarterPlayerScripts named Sprint
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.

Fixed LocalScript in StarterPlayer.StarterPlayerScripts named Sprint
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".

Breaks Script in ServerScriptService named Lava
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.

Fixed Script in ServerScriptService named Lava
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.

For example: Players.Player1.PlayerScripts.Sprint:4: Shift is not a valid member of "Enum.KeyCode"

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

  1. Open Output (Window menu, or the Script tab), clear it with Ctrl+K (⌘K on Mac), and press Play.
  2. Find the first red line. It starts with the script's place in the Explorer and the line number, such as ServerScriptService.Shop:12:.
  3. Click the red line. Studio opens that script with the cursor on the failing line.
  4. Read the lines between Stack Begin and Stack End under it: they list the calls that led there, newest first, so you can see which function called the broken one.
  5. 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.

More Roblox errors

All Roblox Studio errors

Stop hunting errors line by line.

RoCode reads the scripts in your open place, fixes the error where it happens and tells you what it changed. Free every day, no card required.