Syntax
bit32.bor(flags, mask); bit32.band(flags, mask)Examples
Luau bit32 masks
Run as a standalone current Luau script, or as a Script in Roblox Studio ServerScriptService. No Roblox engine APIs are required; type-annotated syntax is not standard Lua.
local READ, WRITE = 1, 2
local flags = bit32.bor(READ, WRITE)
print(flags)
print(bit32.band(flags, WRITE) ~= 0)
flags = bit32.band(flags, bit32.bnot(WRITE))
print(flags)- Output: 3, true, 1. Combining flags sets both bits; masking with the complement removes WRITE.
Best practices
- Keep flag positions within 32 bits and use named constants. Do not assume arbitrary 64-bit integer bitwise precision.
Runtime & versions
Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.
Luau documentation