Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to add strings to messages using tables?

Asked by 10 years ago

In a message, how do you add table strings(?) to the message's text?

table={"hi","pizza","four"}
mes=Instance.new("Message",workspace)
mes.Text=""..table.."" -- trying to make it say: Text="hi, pizza, four"
-- No, I'm not trying to do: mes.Text=""..table[1]..""..table[2]..""..table[3]..""
-- WHAT IS THIS SORCERY

I'm sorry if this is confusing.

1 answer

Log in to vote
2
Answered by 10 years ago

So.. you're trying to make it have all the elements in a table, but not have to list each one individually?

--Anyway if that's what you meant, then use "table.concat".

local table = {"Hey","More pizza","Five"}
mes = Instance.new("Message", Workspace)
mes.Text = table.concat(table," ") 

--The first argument is the table, the second argument is what seperates each element. E.G if I were to put 'table.concat(table,"!")', then the message text would be "Hey!More pizza!Five"

0
Thanks! hievery1 70 — 10y
Ad

Answer this question