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

Can i put objects in a table?

Asked by 8 years ago

for example:

1a = {}
2for i = 1,5 do
3h = Instance.new("Part",workspace)
4table.insert(a,i,h)
5end
6a[1].Anchored = true

will this work?

0
Why couldn't you run this yourself to see if it would work? OldPalHappy 1477 — 8y
0
Sure. Just keep in mind you are not storing the objects themselves into the table, just a reference to them. Link150 1355 — 8y

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago
Edited 8 years ago

Yes.

Also, if you want to save some space, you can create the part and enter it into the table at the same time.

Note: You can leave 'i' out of the arguments in the table.insert function on line 4. The script will default to the succeeding table entry.

1local a = {}
2for i = 1,5 do
3    table.insert(a,Instance.new("Part",workspace))
4end
5a[1].Anchored = true
0
Yeah, i just like the i there just in case mightydifferent 85 — 8y
0
Well, to be more specific about tables, it's like (data) storage. :P TheeDeathCaster 2368 — 8y
Ad

Answer this question