Tables / Dictionaries?

I’m working with Portals here.

So, basically - I’m attempting to create a Portal effect similar to @EgoMoose - However I’m attempting to make my API work across several systems simultaneously.

I’m looking for a way to store my Models and SurfaceGuis in order for them to be updated. I’m not too familiar with Tables and Dictionaries so thought it best to ask others that are familiar?

My current method:
local _List = {TARDIS = {Exterior = Exterior, Interior = Interior}}

I’m wishing to store the: TARDIS model itself, Exterior, Interior, Portal1 and Portal2?

Tables/dictionaries are basically like groups of variables that store certain data/information, sometimes they don’t have to store any information at all, but that’s what they usually do.

Here’s an example:

local PartData = {
  Name = "CoolPart",
  Transparency = .5,
  Color = Color3.fromRGB(255, 255, 0) --Yellow color
  Size = Vector3.new(10, 10, 10)
}

So in this dictionary example I stored information of a random part. The properties you see are Name, Transparency, Color, and Size. The dictionary will apply those properties and change the properties from that random part to their respected values. This is an example of a dictionary that creates new information of a part.

Here’s an example of a dictionary/list of strings that you can use to randomly pick any of those strings to print the string in the Output/Console:

local dictionary = {
  "Cool game!",
  "The developer is awesome!",
  "The playerbase is growing!",
  "Soon, the game will grow big."
}

local randomtext = dictionary[math.random(1, #dictionary)]

print(randomtext) --The output/console will print randomly choose a text from that dictionary and will print that text

Think of arrays/dictionaries as just grouped variables (tables) that can be transferred anywhere. But they are slightly different in what they try to accomplish. They are both tables though at heart.

The scripting definition for a dictionary is just an array with an index that isn’t a number contained within the array. It’s used to better label information, instead of sorting it, unlike an array.
So an example dictionary is

x = {}
x.workspaceObject = game.Workspace

You can now refer to workspace with this

print(x.workspaceObject) --> Workspace
baseplate = x.workspaceObject.Baseplate --> We can also access instances inside the workspace.

This line of code is also doing the same thing, just a different way of doing it. It’s mainly there to allow you to more neatly input objects that aren’t supported by the dot (.) operator, such as instances.
x["workspaceObject"]=game.Workspace

Dictionaries are cool. Because you can also assign instances as indexes too! Everything in the explorer is an instance by the way.

x={}
workspace=game.Workspace
x[workspace]="Hi!" --making the index of the value "Hi!" game.Workspace, using our variable workspace
print(x[game.Workspace]) --> Hi!

So if you wanted to store a TARDIS, you’d do this.

Exterior = game.Workspace.Tardis.Exterior
Interior = game.Workspace.Tardis.Interior 
local _List = {TARDIS1 = {Exterior = Exterior, Interior = Interior}}

And to understand how to access said information is very simple.

print(_List.TARDIS1.Exterior) -- will give us the game.Workspace.Tardis.Exterior, since we defined Exterior as _List.TARDIS1.Exterior previously

To describe an array, it’s just the same thing as a dictionary but more simple. There are only numbers as indexes. The values can be anything however, tables, functions, and the like. They are used for sorting information unlike dictionaries, because you can use the “#” operator on them, unlike dictionaries. Which is the primary distinction between the two.

z={[2] = true}
z[1] = "Hi!"
print(z[1]) --> Hi!
print(z[2]) --> true
print(#z) --> 2, because there are two different indexes, that lead to two values.

Please reply with any questions.