How would i do a search manager

Hello!, How would i do a search manager, When you type something on it, the algorithm Searchs for the first letter like if you put “a” it searchs objects in workspace with the letter “a” or a specific name

1 Like

You could just use a searching algorithm like a linear search to go through all the objects within the workspace and see if they contain the letter a and just return a table of everything that does.

2 Likes

Yeah, that was what i had in mind, but if there’s a module for it i will use it, Since i couldn’t find nothing until now

you dont need a module for something as simple as a loop with string function

– .changed event
– get children of folder
– check if object start with the string
– insert to table and return

local function findInstancesMatchingName(s, f)
	local foundInstances = {}
	f = f or workspace
	for _, instance in ipairs(f:GetDescendants()) do
		if instance.Name:match("^"..s) then
			table.insert(foundInstances, instance)
		end
	end
	return foundInstances
end

Here’s a function which has two parameters, s and f, s represents the search string and f represents the folder where the search should be conducted (workspace is the default so this parameter is optional). The search string doesn’t need to perfectly match the names of the instances being iterated over, it just needs to match the start of those names.

1 Like

This can be done with “string.find” ?

Yes, match() can be replaced with find() instead.

1 Like