Types
local Operator = require(game:GetService("ServerStorage").Operator)
local Types = Operator.Types
-- or
local Types = Operator.TypesThe nine built-in argument types. All are registered on a fresh Registry already, so you can use them without registering anything.
| Type | Accepts | Produces |
|---|---|---|
Types.String | anything | string |
Types.Number | 42, -3.5 | number |
Types.Integer | 42, -7 | number |
Types.Boolean | true/yes/y/1/on and their negatives | boolean |
Types.Duration | 30, 30s, 5m, 1h30m, 1.5h, 2d, 1w | number of seconds |
Types.Player | @me, a name, an unambiguous prefix | Player |
Types.Players | @me, @all, @others, names, comma lists | { Player } |
Types.Team | a team name or unambiguous prefix | Team |
Types.BrickColor | a palette colour name | BrickColor |
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.
| Input | Seconds |
|---|---|
30 | 30 |
30s | 30 |
5m | 300 |
1h30m | 5400 |
1.5h | 5400 |
2d | 172800 |
1w | 604800 |
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:
| Selector | Meaning |
|---|---|
@all | everyone in the server |
@others | everyone 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:
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.