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

How do I add Values to an Array?

Let's say I have an Array {"Hi", "Bye", "Welcome"} and I want to add an "Potato" on the [4] how can I do that? Thanks!

1 answer

✓ Accepted answer

Using table.insert.

Pretty easy actually;

local aa={'a',1}

table.insert(aa,3,'b') --1st argument is the table, 2nd one is the position, 3rd is the value(string, bool, int).

--To make it so it's at the last position.
table.insert(aa,#aa+1,'last')

EDIT* Made a mistake, 2nd argument is the position, the 3rd is the value.

2 comments

0

If i want it to be added at the end, I use #aa + 1?

1

Made a mistake. Fixed it though.

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