TypeCoercer → Supported Types
Supported Types
Every type name that TypeCoercer recognises, what input it accepts, and the Luau result type returned on success. Pass the type name as the second argument to Coerce, or as a schema value in CoerceTable.
| Type name | Coerces from | Result type | Notes |
|---|---|---|---|
string | any value | string | Passes through as-is via tostring. |
number | "42", "3.14" | number | Fails if the string cannot be parsed as a number. |
int | "42" | number | Rejects decimals — must be a whole number string. |
boolean | "true", "false", "1", "0" | boolean | Case-insensitive. |
vector2 | "x,y" | Vector2 | |
vector3 | "x,y,z" | Vector3 | |
cframe | "x,y,z" or "x,y,z,rx,ry,rz" | CFrame | Rotation as Euler degrees. Position-only form produces identity rotation. |
color3 | "r,g,b" | Color3 | Auto-detects 0–255 vs 0–1 on input; always outputs 0–255 internally. |
udim | "scale,offset" | UDim | |
udim2 | "xs,xo,ys,yo" | UDim2 | Four comma-separated values: X scale, X offset, Y scale, Y offset. |
rect | "minX,minY,maxX,maxY" | Rect | |
Enum.TypeName | "ValueName", "Enum.TypeName.ValueName", or numeric value | EnumItem | Exact enum type required, e.g. "Enum.CameraType". |
Enum | "Enum.TypeName.ValueName" | EnumItem | Accepts any EnumItem; wire string must carry the full type path. |
Instance | "ClassName:Name" | Instance | Requires at least one registered instance root. See TypeCoercer Guide. |
Wire format examples
local TC = RoExpress.TypeCoercer
TC.Coerce("10,5,-20", "vector3") -- Vector3.new(10, 5, -20)
TC.Coerce("255,0,128", "color3") -- Color3.fromRGB(255, 0, 128)
TC.Coerce("1,2,3,0,0,0", "cframe") -- CFrame at (1,2,3)
TC.Coerce("Scriptable", "Enum.CameraType") -- Enum.CameraType.Scriptable
TC.Coerce("Part:Baseplate", "Instance") -- workspace.Baseplate
TC.Coerce("0.5,10", "udim") -- UDim.new(0.5, 10)
TC.Coerce("0,0,100,50", "rect") -- Rect.new(0, 0, 100, 50)
See also
← TypeCoercer · Coerce | Coerce and CoerceTable method signatures · TypeCoercer Guide | usage patterns with routes and DataStore