I never got how people used ipairs, pairs, or #. It's like... I just don't get it.
ipairs
and pairs
are simply built in functions that iterate through arrays/tables. They are there for convenience so you don't have to write your own. These are used in generic for loops.
Usage example:
local array = { [index] = value, [2] = "b", ["Apple"] = "Banana" } for index, value in ipairs(array) do print(index, value) end --[[Output index output 2 b Apple Banana --]]
#
is used to retrieve the number of items in an array/table. These are commonly used in basic for loops.
Usage Example:
local array = {1, "Apple", game.Workspace} for i = 1, #array do print(array[i]) end --[[Output 1 Apple Workspace --]]