I’m trying to find some words in a table, add those words in a seperate table, then unpack it for string concatenate, but it only returns first index.
local text = "hi this is a test that contains some words that are in a cool table"
local words = {
"test",
"cool",
"words",
"some"
}
local splitedtext = text:split(" ")
local found = {}
for _,v in splitedtext do
if table.find(words, v) then
table.insert(found, v)
end
if v:find("contain") then
table.insert(found, v)
end
end
print(found) -- Returns all found words
print("bannable words "..table.unpack(found)) -- Only returns test
What the very cool boy above said is the reason, just to add to that, you perhaps meant to use table.concat() to concatenate the table into a unified string.
local separator = ""
print("Content: " .. table.concat(table.pack("element1", "element2"), separator))