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

Can i put objects in a table?

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?

2 comments

0

Why couldn't you run this yourself to see if it would work?

0

Sure. Just keep in mind you are not storing the objects themselves into the table, just a reference to them.

1 answer

✓ Accepted answer

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

2 comments

0

Yeah, i just like the i there just in case

0

Well, to be more specific about tables, it's like (data) storage. :P

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