How can I find out the number of objects (after commas) in such brackets?
local rarityColors = {FDG, DFG, WER, GFH}
Method 1
Using the "for i,v" loop, we can determine how many objects are in a table.-- pairs sub-method
for _, color in pairs(rarityColors) do
-- do whatever
end
-- ipairs sub-method
for _, color in ipairs(rarityColors) do
-- do whatever
end
Method 2
Using the "getn" function from "table". It is a shorten version of the "for i,v" loop.local Amount = table.getn(rarityColors)
-- do whatever
Method 3
Using the "#" indicator before the table variable.local Amount = #rarityColors
-- do whatever
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.