Ahoy! I am making a script that sorts letters into a table from a string, and it seems as it is only returning the last letter of the string? Any support would help.
obj = "Lorem ipsum sit dolor amet"
for i = 1,#obj do
cletter = string.sub(obj,i,i)
letters = {}
table.insert(letters,#letters+1,cletter)
end
print(letters)
I’m not sure what you mean about sorting (alphabetically or anything) but if you just want to convert a string into a table of characters you can use the :split() function.
obj = "Lorem ipsum sit dolor amet"
letters = obj:split("")
also remember to concat tables when printing to the output: