I also inserted the characters into a table instead and concatenated the results altogether into 1 string via table.concat. Concatenating would create a new string each iteration which can be slow.
I had a feeling i needed to organize it into tables like that. However, one thing i never understood is the use of table.concat. Anyways, tysm for the help!
table.concat(t, delimiter, i, j) concatenates all the strings and numbers in a table to 1 string. delimiter is what to separate each element with. Defaults to an empty string "", i is where to start concatenating. By default this is 1. j is where to stop concatenating. Defaults to #t.