while learning how to code, I have kept seeing some people use a table without anyone inside like this:
local table = {}
i keep on wondering and thinking if that means it’s empty or there are something in it. Also i wonder on what those are used for. Any help would be great, thanks!
Yes, this is an empty table. But you should not name a table "table", because that is a special keyword on roblox. Any text that turns blue is a special keyword you should not use to name anything in your code. Tables are basically arrays or a list. They can store information like strings, booleans, functions, and more. Usually people use them to store items in a player's inventory.
local myTable = {} -- Empty table.insert(myTable, "Oranges") -- Inserting the string "Oranges" print (myTable[1]) -- Printing the first item in our table: Oranges -- Inserting Apples, Grapes, and Bananas table.insert(myTable, "Apples") table.insert(myTable, "Grapes") table.insert(myTable, "Bananas") table.remove(myTable, 3) -- removing the 3rd item in our array/table/list: Bananas for i, v in pairs(myTable)do -- printing every item in our list print (i, v) end