Modulescript question

Hi, I wanted to ask if I add a value to a table in a ModuleScript (from a function in that modulescript), if other scripts requiring it will be able to see it.

What do you mean by that? I’m going to assume you mean something like this, correct?

local tab = {}

function tab:AddValue()
   tab.ValueAdded = 50
   return tab.ValueAdded
end

return tab

Other scripts will be able to see that once the value has actually been added.

1 Like

You can create a table through a module but once the function has finished the table will be gone, a good theory but ive tried it before.

I belive the only exception is if its created outside of the module but im not too sure if the scripts will have acces to the array through the module or not

Say this is your module:

local module = {}

function module:getTable()
	local newTable = {
		index = "variable"
	}
	return newTable
end

return module

You could print the table from a separate script by doing something like this:

local module = require(modulePath)

print(module:getTable())

And you could go off that and do whatever.