Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Im confused about what an "enum" is, can someone explain?

Asked by 3 years ago

Ive always been confused about what an enum is. Ive used them before with UserInputService but I never knew what the enum does or what it means. Can someone explain, thankss.

0
I googled and got this An enumeration — sometimes shortened to “enum” — is a special data type that can take one of a set of values. For example, the Material enum represents the material type for a part. See the Enum Index for a full list of enum types in Roblox. In a script, enums are accessed through a global object called Enum .link:https://developer.roblox.com/en-us/articles/Enumeration#:~:te robot7866 36 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Enum is short for enumeration. Basically if you're trying to change say the material of a part which has a selection of mats for you to choose from (brick, neon, smooth plastic, etc), you use enum.

Part.Material = Enum.Material.SmoothPlastic

UserInputService is another thing you can use enums for. Say you're trying to detect when a player presses E. There's a selection of keys that you can choose from (W, Space, LeftAlt, RightShift, etc).

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        --blah blah blah
    end
end)
Ad
Log in to vote
0
Answered by
Oxprem 140
3 years ago

If you want to learn more about Enum, click here.

Answer this question