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:

-- ModuleScript
local module = {}

local val = math.random(2, 10)

module.PathToPart = workspace.Part

module.ClearUnnamedParts = function()
    local desc = workspace:GetDescendants()
    for _, descendant in desc do
        if descendant.Name == "Part" then
            descendant:Destroy()
        end
    end
end

return module

-- Does this code get copied whenever required?
-- 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