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

How can I make a print function only unpack the first string of a table?

In the outcome of this it prints both strings, how can I make it only print the first one?

ta = {"123335","123124124"}

print(table.unpack(ta))

1 answer

✓ Accepted answer

table.unpack and table.pack are purely Lua 5.2+ features. That being said, unpack is still the wrong tool for the job here. If you only care about the first entry in the table, unpacking the entire thing is not necessary. Just index the array for it's first element:

local ta = {"123335","123124124"}

print(ta[1])

2 comments

0

exactly (pack is a thing?)

0

Ask JavaScripts shift, pop, push:)

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