Help with table.insert

I want to insert something like this:

	foo = {
		Power = 123;
		Health = 123;
	};

But as far as I know, when you use table.insert inserts something like this:

[2] = "foo"

No idea how to do this.

You do this:

table.insert(foo, YourItem)
-- For the first variable, out the name of the table
-- For the second, but the object you want to insert

I dum tho lol

table.insert is used for lists

local foo= {}
table.insert(foo, 'john')
table.insert(foo, 'mike')
print(foo) -- {'john', 'mike'}

for a dictionary you would do this instead

local foo = {}
foo.Health = 123
foo.Power = 123

print(foo) = 	--foo = {
		--Power = 123;
		--Health = 123;
	--};
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.