local itemarray = {script.Parent.String1.Value,script.Parent.String2.Value,script.Parent.String3.Value} local text = script.Parent.Test text.Text = itemarray[1],itemarray[2],itemarray[3]
Im experimenting with tables and I would like to add the names listed on that table to a gui. this script only adds itemarray[1] .
To connect strings in roblox you use ..
instead of ,
So what you want to do is
Text = itemarray[1]..itemarray[2]..itemarray[3]
Your welcome!
You can use table.concat()
to do this:
local str = table.concat(itemarray, " ") -- Concatenate every index in the array with a whitespace between each index 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:
" "
), 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()
.