Is it possible to require() a Module script that you used Instance.new() to create? For example,
local BM = Instance.new('ModuleScript')
local BMData = require(BM)
BM.Name = 'BMData'
I tried this approach, and was given an error with the Module not loading. Is this something that’s not possible to do, or is it done differently?
Jxl_s
(Jxl_s)
April 21, 2021, 3:45pm
#2
Most likely, it’s because the module script is not returning anything when you create it.
1 Like
dukzae
(dukzae)
April 21, 2021, 3:45pm
#3
Why would you need to require an empty module?
2 Likes
How would I go about making it not empty, in that case. I just assumed that the code was the same as the default ModuleScript code.
Harishxx
(Windy)
April 21, 2021, 3:46pm
#5
You could use Instance:Clone()
on another module script maybe?
1 Like
I’m using a ModuleScript to save PlayerData, and am creating a new one for each.
Jxl_s
(Jxl_s)
April 21, 2021, 3:47pm
#7
You should consider using object-oriented programming if you are doing that.
a topic that might be helpful: All about Object Oriented Programming
1 Like
dukzae
(dukzae)
April 21, 2021, 3:47pm
#8
The default ModuleScript code can also count as empty; as for your question, there is no way to go about this without using hacky solutions such as plugins, which of course don’t run in any instances other than Studio.
1 Like