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

Can someone explain and tell me the functions and how to use tables?

1 answer

✓ Accepted answer

table:

first define a variable, then create a table.

local someting = {} 

as you see, "{}" is the table, although, it is an empty table, tables can be used to store many numbers and letters and sentences perhaps in it,

there are many things to do with tables, suppose you have a list in replicated storage and want to create an anti hack script, you would create a table with a list in them and make sure nothing else is added to the list in replicated storage.

You can not only create an empty table but also, an already filled table, example:

local table1 = {"something","somethingelse.."}
for _, v in pairs(table1) do
	print(v)
end

Also when looping with tables, don't add the :GetChildren() because, it isn't an object, it is a table, a special class.

In order to add and remove items within a table, try this:

local initial_Table = {"DeleteMe"'}
table.Insert(initial_Table,"Something")
table.Remove(initial_Table,"DeleteMe")

as you see, "something" will be added to the table and DeleteMe will be removed.

There are also dictionaries, something like this, the coding can change a bit here:

local diction = {["Walking"] = false, ["Standing"] = true}
for i,v in pairs(diction) do
	print(i)
	print(v)
end

And that is basically, all you need to know, go to the links in the comments, k bye

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