Skip to main content

Types

By default, these types are available:

Possibly outdated

We've not reviewed this section for a while, it's possible that this information may be out of date.

Type nameLuau typeType nameLuau type
stringstringstrings{string}
numbernumbernumbers{number}
integernumberintegers{number}
booleanbooleanbooleans{boolean}
playerPlayerplayers{Player}
playerIdnumberplayerIds{number}
teamTeamteams{Team}
teamPlayers{Player}
commandstringcommands{string}
userInputEnum.UserInputType | Enum.KeyCodeuserInputs{Enum.UserInputType | Enum.KeyCode}
brickColorBrickColorbrickColors{BrickColor}
teamColorBrickColorteamColors{BrickColor}
color3Color3color3s{Color3}
hexColor3Color3hexColor3s{Color3}
brickColor3Color3brickColor3s{Color3}
vector3Vector3vector3s{Vector3}
vector2Vector2vector2s{Vector2}
durationnumberdurations{number}
storedKeystringstoredKeys{strings}
urlstringurls{strings}

The type name is what you'd include in your command definition, while the Luau type is what your command implementation would get (this is also called the 'transformed value').

Plural types (types that return a table) are listable, so you can provide a comma-separated list of values.

Custom types are defined as tables that implement specific named functions. When Types are in a ModuleScript, the ModuleScript should not return the table directly; instead it should return a function, which accepts the Registry as a parameter. You should then call registry:RegisterType("typeName", yourTable) to register it. This is important because if a type is only registered on one realm (the client but not the server, or vice versa) then it may cause unexpected bugs and errors.

Check out the API reference for a full reference of all available options.

local intType = {
Transform = function(text)
return tonumber(text)
end,

Validate = function(value)
return value ~= nil and value == math.floor(value), "Only whole numbers are valid."
end,

Parse = function(value)
return value
end,
}

return function(registry)
registry:RegisterType("integer", intType)
end

Take a gander at the built-in types for more examples.

Default value

You can specify a "default value" for your type by adding a Default function to it. For example, the default value for the players type is the name of the player who ran the command. The Default function should always return a string, as this is inserted before parsing.

For any argument whose type has a default value, you can simply input . and the default value will automatically be used in its place. E.g. kill .

Enum types

Because Enum types are so common, there is a special function that easily lets you create an Enum type. When a command has an argument of this type, it'll always be a string matching exactly one of the strings in the array you define (see below).

return function (registry)
registry:RegisterType("place", registry.Cmdr.Util.MakeEnumType("Place", {"World 1", "World 2", "World 3", "Final World"}))
end