How to use string.match

How do I use string.match to search through a folder and find items that have a certain word in them?

Call Instance | Roblox Creator Documentation or Instance | Roblox Creator Documentation on the folder to get a list of items (GetDescendants is recursive).

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!")

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 string.find()/:find() instead.

More information: