So I wanted to know how to make a table add numbers inside of it, for example
local table = {1, 2, 3}
becomes 6 in the end
Ask me more questions if you still don't understand :)
So I wanted to know how to make a table add numbers inside of it, for example
local table = {1, 2, 3}
becomes 6 in the end
Ask me more questions if you still don't understand :)
Simply iterate through the table with pairs and add each value to a variable:
local function AddTable(Table)
local Total = 0
for _,Value in pairs(Table) do
Total = Total + Value
end
return Total
end
local TableToAdd = {1,2,3}
print(AddTable(TableToAdd)) --> 6
This discussion is preserved as it was. New answers, comments, and votes are closed.