Will this module script work for my electronic game?

You can write your topic however you want, but you need to answer these questions:

  1. I want to know if this will work for my electronic game

  2. I don’t know if this will work.

  3. I have not tried anything yet.

local ElectronicsFolder = game.ReplicatedStorage.Electronics

local Electronics = {
	["Electronic1"] = ElectronicsFolder.Electronic1,
	["Electronic2"] = ElectronicsFolder.Electronic2
}

local Electronicite = {
	["Electronicite1"] = 0.1;
	["Electronicite2"] = 0.5;
}

Will this work?

What specifically do you need help with?

To know if for my game if this is the correct script for a module.

I’m pretty sure this is fine, just make sure you nest the Electronics and Electronicite tables under 1 housing table:

Module Script:

local ElectronicsInfo = {

    Electronics = {
	    ["Electronic1"] = ElectronicsFolder.Electronic1,
     	["Electronic2"] = ElectronicsFolder.Electronic2
    },

    Electronicite = {
  	    ["Electronicite1"] = 0.1;
	    ["Electronicite2"] = 0.5;
    }

}

return ElectronicsInfo

Server Script:

local ElectronicsInfo = require(game.ServerStorage.ElectronicsInfo)
print(ElectronicsInfo.Electronics) --> prints ["Electronic1"] = Instance, etc.
print(ElectronicsInfo.Electronicite) -- > prints ["Electronicite1"] = 0.1
2 Likes

No. You need to return exactly one value in a module. You’re not far off though, but you should go check out a module tutorial.

That makes sense now. You need to organize it first I just realized. Thanks for the help.

So now like this?

local ElectronicsFolder = game.ReplicatedStorage.Electronics

local ElectronicInfo = {
	
	Electronics = {
		["Electronic1"] = ElectronicsFolder.Electronic1,
		["Electronic2"] = ElectronicsFolder.Electronic2
	},

	Electronicite = {
		["Electronicite1"] = 0.1;
		["Electronicite2"] = 0.5;
	}
}

return ElectronicInfo

Yes, make sure this is in a module script too!

Ik! I already put it in a module before I posted this topic. Don’t worry :slight_smile: