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 7 years ago

for example:

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

will this work?

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

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 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.

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

Answer this question