I understand how tables work and mostly everything about them, but I've just never come across a time where I needed to use them in scripts. I feel like there's probably somewhere in my scripts where instead of doing what I did, I could use a table and make things a lot easier and organized.
So I guess it'd be nice to include some examples that you've used tables in your scripts so I can get a better understanding of when to use tables for mine.
if part.Name == "Name1" or part.Name == "Name2" then
, but that can get very messy. You'd use a type of table called a dictionary
.local parts = { ["Part1"] = true, -- you'd put the name of the part in between the [""] ["Part2"] = true, ["Part3"] = true, ["Part4"] = true, ["Part5"] = true } local children = workspace.Model:GetChildren() -- an example for _, child in pairs(children) do -- loop through children if child:IsA("BasePart") then -- check if they're a part if parts[child.Name] then -- if their name is in the dictionary! child.BrickColor = BrickColor.Red() child.Transparency = 0.375 child.Material = Enum.Material.Neon end end end