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 nameCoerces fromResult typeNotes
stringany valuestringPasses through as-is via tostring.
number"42", "3.14"numberFails if the string cannot be parsed as a number.
int"42"numberRejects decimals — must be a whole number string.
boolean"true", "false", "1", "0"booleanCase-insensitive.
vector2"x,y"Vector2
vector3"x,y,z"Vector3
cframe"x,y,z" or "x,y,z,rx,ry,rz"CFrameRotation as Euler degrees. Position-only form produces identity rotation.
color3"r,g,b"Color3Auto-detects 0–255 vs 0–1 on input; always outputs 0–255 internally.
udim"scale,offset"UDim
udim2"xs,xo,ys,yo"UDim2Four 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 valueEnumItemExact enum type required, e.g. "Enum.CameraType".
Enum"Enum.TypeName.ValueName"EnumItemAccepts any EnumItem; wire string must carry the full type path.
Instance"ClassName:Name"InstanceRequires 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