Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

adding the names inside from a table to a text label gui?

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] .

1 comment

2 answers

✓ Accepted answer

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!

2 comments

0

table.concat() is way easier.

0

ok

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:

  1. The array to concatenate. As I already said, this parameter must be an array.
  2. 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().

This discussion is preserved as it was. New answers, comments, and votes are closed.