As we all know, using spawn() will allow us to execute functions in parallel. However, how can we share memory so that what happens on one function can be checked by the other function?
I suppose one of the answer is using global scope variables with _G but this will make it global thru all scripts. What are some other ways and perhaps with more restricted scope?
You could use modulescripts for this. Unlike what KingLone said, you can not "share" variables with RemoteFunctions or BindableFunctions, only the values of those variables. You can create a module that returns variables, and only scripts that are able to require it will be able to acces- and change those values
For example, within a ModuleScript:
local module={ a=true, b="hi!", c=4, } return module
Inside a serverscript:
local returnedTable=require(modulescript) print(returnedTable.a) print(returnedTable.b) print(returnedTable.c)