✓ Accepted answer
tables have a built-in function for checking a table for a value / finding a value:
table API
Variant table.find ( table haystack, Variant needle, number init )
The first argument is the table you want to search.
The second argument is the element you are searching the table for.
The last argument is the starting index, or the place in the table you want to start searching. If the last argument is not given, it will start searching from the beginning.
Keep in mind, if the element is NOT found, it will return nil
An example taken from the 'table' API:
local t = {"a", "b", "c", "d", "e"}
print(table.find(t, "d"))
print(table.find(t, "z"))
print(table.find(t, "b", 3))
In your case, you could do this:
local members = {'Player1', 'Player2', 'Player4'}
if table.find(members,player.Name) ~= nil then
print('A Member')
else
print('Not a Member')
1 comment
Thank you!