You can use table.concat() to do this:
local str = table.concat(itemarray, " ")
script.Parent.Test.Text = str
So you may be asking "Well, what is table.concat()?". It is a function that concatenates the given array (it can only concatenate arrays, giving it a dictionary will result in an error) with a separator. The parameters that you should pass:
- The array to concatenate. As I already said, this parameter must be an array.
- The string that acts as the separator between indices. This can be anything you want. With a whitespace as a string (
" "), each index is separated by that whitespace. (optional)
With long tables, doing what the other answer did above would take a really long time. It's all about efficiency in programming, which is why you should use table.concat().
1 comment
https://developer.roblox.com/api-reference/lua-docs/table#concat