to_bool
Coerce a value to true or false.
Syntax
Section titled “Syntax”bool to_bool(value);Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
value | any | Value to coerce. |
Return value
Section titled “Return value”bool
Luau emit
Section titled “Luau emit”not not (value)
Description
Section titled “Description”null, false, and 0 are falsey in Luau; everything else is truthy. Prefer a real bool when you can.
Example
Section titled “Example”Instance child = folder.FindFirstChild("x");bool exists = to_bool(child);Emits:
local child: Instance = folder:FindFirstChild("x")local exists: boolean = not not (child)