Skip to content

Types

luau
local Operator = require(game:GetService("ServerStorage").Operator)
local Types = Operator.Types
-- or
local Types = Operator.Types

The nine built-in argument types. All are registered on a fresh Registry already, so you can use them without registering anything.

TypeAcceptsProduces
Types.Stringanythingstring
Types.Number42, -3.5number
Types.Integer42, -7number
Types.Booleantrue/yes/y/1/on and their negativesboolean
Types.Duration30, 30s, 5m, 1h30m, 1.5h, 2d, 1wnumber of seconds
Types.Player@me, a name, an unambiguous prefixPlayer
Types.Players@me, @all, @others, names, comma lists{ Player }
Types.Teama team name or unambiguous prefixTeam
Types.BrickColora palette colour nameBrickColor

Primitives

Types.String

Accepts anything and produces it unchanged. Pair with { rest = true } to capture the remainder of the line as one string.

Types.Number

Produces a number, rejecting NaN and infinity.

Types.Integer

Produces a number, rejecting fractions.

Types.Boolean

Accepts true, yes, y, 1, on and their negatives false, no, n, 0, off, case-insensitively. Suggests true and false.

Types.Duration

Produces a number of seconds.

InputSeconds
3030
30s30
5m300
1h30m5400
1.5h5400
2d172800
1w604800

A bare number is seconds. Units may be combined and may carry a decimal.

Player types

Types.Player

Resolves exactly one Player.

  • @me: the executor
  • an exact name or display name, case-insensitively. An exact match always wins
  • a unique prefix of either
  • an ambiguous prefix is rejected with the candidates listed

Players match on both Name and DisplayName, and two labels pointing at the same player do not count as ambiguous.

A comma list is rejected outright, since this type resolves exactly one player.

Types.Players

Resolves a list of players, { Player }.

Everything Types.Player accepts, plus:

SelectorMeaning
@alleveryone in the server
@otherseveryone except the executor

Also accepts comma-separated lists such as bob,alice or @others,bob, mixing freely with selectors. Duplicates are removed, so @all,@me yields each player once. An empty entry (bob,,alice) is rejected, and if any entry fails the whole argument fails.

Game types

Types.Team

Resolves a Team by name or unambiguous prefix, case-insensitively. Same matching rules as players: exact wins, unique prefix accepted, ambiguous rejected with candidates.

Types.BrickColor

Resolves a BrickColor by palette colour name.

Composing on them

:extends runs a built-in's transform first and feeds the result forward, so you never reimplement parsing:

luau
local PositiveInteger = Type.new("positiveInteger")
	:extends(Types.Integer)
	:transform(function(value)
		if value <= 0 then
			return false, "expected a number above zero"
		end
		return true, value
	end)
	:build()

See Type for the full builder.

Released under the MIT Licence.