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

Is it possible to set a Boolean after "table.find", if it finds it or not?

I got a table of sweets;

local table = {Chocolate, Fudge, Caramel, Marshmallows}

I then use table.find to see whether a sweet is in it:

Table.find(table1, "Croissants")

Is it possible to set a variable after I did Table.find(table1, "Croissants") to the answer of the find (true or false)?

1 answer

✓ Accepted answer
local a = false

if table.find(you_cant_have_table_as_your_tables_name, "Croissants") ~= nil then
	a = true
end

change your table's name; it can't be a keyword

3 comments

1

What does the " ~= nil" part mean

0

~= stands for different than, different than nil, if it's different than non-existing

0

Not equal to is also a different meaning, ~ is not = equal, ~= is not equal to.

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