Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What other way can you use the table?

Asked by 3 years ago

I know that the table you can use many things with the for i,v in pairs do but i know that you can put Model:GetChildren() and Players:GetPlayers() but what else can you use it for?

for i,v in pairs(what else can we do here?) do

end
0
You can use it to store data within it such as items and create 'Dictionaries' which lets you set keys into values. DiamondComplex 285 — 3y

2 answers

Log in to vote
1
Answered by
Mroczusek 111
3 years ago

Oh, boy, there's a lot of uses for a table!

For an example, you can use it instead of using a lot of elseifs, a table can also be used to store per say userIds so you can make admin commands, or you can make whitelists.

However, I might've misunderstood your question, so, what else can we do inside of the brackets? Well, the only thing you can do there is provide a table, nothing else, that loop is made for iterating through tables.

Hope I answered your question, feel free to comment on my post if you'd like to ask about anything else.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You can also do Randomisers, like for example:

Colors = {
    "New yeller";
    "Really Red";
    "Electric blue";
    "Lime green";
}

ColorChosen = Colors[math.random(1,#Colors)]

script.Parent.BrickColor = BrickColor.new(ColorChosen)

Use this script as an help to your randomisers C:

You can also use: >game.ServerStorage:GetChildren() as an table

0
Thank you I really appreciate it. mastercheeseit 77 — 3y

Answer this question