Syntax
local index = table.find(items, value, startIndex)Examples
Luau sequence searches
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 names = {"Ada", "Lin", "Ada"}
print(table.find(names, "Ada"))
print(table.find(names, "Ada", 2))
print(table.find(names, "Bo") == nil)- Output: 1, 3, true. An optional start index allows searching beyond the first occurrence.
Best practices
- Check for nil before removal or indexing. For repeated membership checks over large data, consider a dictionary set.
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