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

Do ModuleScripts copy a table or point to it?

Asked by 5 years ago
Edited 5 years ago

Recently, I have been making a ModuleScript that handles the behavior of multiple buttons. However, I started to wonder more about how ModuleScripts work. Do ModuleScripts return a copy of the table in a ModuleScript or point to the table in the module?

For example:

01-- ModuleScript
02local module = {}
03 
04local val = math.random(2, 10)
05 
06module.PathToPart = workspace.Part
07 
08module.ClearUnnamedParts = function()
09    local desc = workspace:GetDescendants()
10    for _, descendant in desc do
11        if descendant.Name == "Part" then
12            descendant:Destroy()
13        end
14    end
15end
16 
17return module
18 
19-- Does this code get copied whenever required?
20-- If not, are there any exceptions, like local variables?
1
Point. Kind of like a global variable. PhantomVisual 992 — 5y
0
Thanks! SaltyIceberg 81 — 5y

Answer this question