Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how do you search for a item in a table?

is there anyway to search for a item in a table by its name?

2 comments

0

yes there is. problem solved

0

link? please

1 answer

✓ Accepted answer

Yes. You can use a for loop:

Let's say you have a table with 2 items: Item1 and Item2. You want to find Item2 from the table.

local myTable = {
	"Item1",
	"Item2"
}

for _,object in pairs(myTable) do
	if object == "Item2" then
		print("Item2 found!")
	else
		print("This item is not Item2.")
	end
end

Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.