How do I use string.match to search through a folder and find items that have a certain word in them?
Loop through that list and call
string.match on each item’s
Name, following the documentation on
string.match that you can find here.
local Folder = workspace.Folder --example for _, Child in ipairs(Folder:GetDescendants()) do --can be GetChildren() if needed if Child.Name:match("Part") then --search for child instances which contain the word "Part" in their names print(Child.Name.." was found!") end end
If you only plan on searching for non-pattern strings, such as in the above example, and don’t intend to make use of Lua’s pattern searching capabilities (character classes, character ranges, modifiers etc.) then consider using