Help with tables

Hi,

Im making a table. So heres the script.

local TableOfParts = {
    local Part = game.Workspace.Part
}

TableOfParts.Visible = false

The script doesn’t work.

local Part = game.Workspace.Part --an object

--a dictionary(its keys are strings)
local TableOfParts = { --a table
	[Part.Name] = Part
}
print(TableOfParts[Part.Name])

--an array(its keys are numbers)
local TableOfParts = {
	Part
}
print(TableOfParts[1])

You can find a lot useful info about how tables work here.

2 Likes

You would need to loop through the table if you wanted to make multiple parts invisible at once.
Visible is not a property of a part.

local TableOfParts = {
    Part = game.Workspace.Part
}

then

TableOfParts.Part.Transparency = 1 -- for a specific part

or

for i,v in pairs(TableOfParts) do -- for all parts
    v.Transparency = 1
end

this might work

local Part = workspace.Part

local TableOfParts = {Part}

TableOfParts[1].Visible = false