Making search bar

I Want to make a search bar for searching item assets

Problem is script can’t find it only finds when i typed whole word

function SearchInventory()
	local search = string.lower(SearchBox.Text)
	
	for i,item in ipairs(Assets.Weapon:GetChildren()) do
		local search = string.lower(SearchBox.Text)
			if item:IsA("Folder") then
				if search ~= "" then
					local item = string.lower(tostring(item.Name))
					if string.find(item, search) then
						warn("a1")
					else
					warn("a2")
					end
				else
				warn("a3")
			end
		end
	end
end

SearchBox:GetPropertyChangedSignal("Text"):Connect(function() SearchInventory() end)

switch them, they’re backward

string.find(search, item)

Also, you defined the variable search twice

function SearchInventory()
local search = string.lower(SearchBox.Text)

for i,item in ipairs(Assets.Weapon:GetChildren()) do
	local search = string.lower(SearchBox.Text)
		if item:IsA("Folder") then
			if search ~= "" then
			local item2 = string.lower(tostring(item.Name))
			if string.find(search, item2) then
				warn("a1")
			else
				warn("a2")
			end
		else
			warn("a3")
		end
	end
end

end

02:18:24.778 :arrow_forward: a2 (x22) - Client - InventoryClient:143
02:18:30.544 a1 - Client - InventoryClient:141
02:18:31.427 a2 - Client - InventoryClient:143
02:18:31.527 a1 - Client - InventoryClient:141
02:18:33.927 a2 - Client - InventoryClient:143
02:18:34.011 a1 - Client - InventoryClient:141
02:18:34.794 a2 - Client - InventoryClient:143
02:18:34.844 a1 - Client - InventoryClient:141

Nope still same i have to type entire word

sorry, I had it wrong, item is before search

string.find(item2, search)

Oh, and the text in the box can ONLY be accessed on the client.

I think it works now lel Thanks!

And it is on client

Yah, should’ve realized. It wouldn’t work at all without it being on the client
Glad you found the solution!! :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.