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

Can I check if a word is inside a list?

Hey, I am wondering if I could check if a word is inside of a list. For example, I have:

local List = {"Red","Blue","Green"}

During part of my code, I need to check if a parts name is inside the list. I was wondering if there was a basic way of doing this?

I know I can use

i,v in pairs(List) do
	if Part.Name == v then end
end

but is there any simpler way?

2 comments

0

This already is a very simple way and I don't think there is an easier way.

0

why use i,v in pairs?

1 answer

You can use Gmatch or you could use this to find something

local List = {"Red","Blue","Green"
local find = "FindThisItem"
for _, v in pairs(List) do
	if v.Name == find
end

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