Nkk2356
(Nkk2356)
March 22, 2021, 9:23pm
#1
You can write your topic however you want, but you need to answer these questions:
I want to know if this will work for my electronic game
I don’t know if this will work.
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?
Afrxzo
(AFRXOGUNS)
March 22, 2021, 9:39pm
#2
What specifically do you need help with?
Nkk2356
(Nkk2356)
March 22, 2021, 9:40pm
#3
To know if for my game if this is the correct script for a module.
Afrxzo
(AFRXOGUNS)
March 22, 2021, 9:47pm
#4
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.
Nkk2356
(Nkk2356)
March 22, 2021, 9:48pm
#6
That makes sense now. You need to organize it first I just realized. Thanks for the help.
Nkk2356
(Nkk2356)
March 22, 2021, 9:51pm
#7
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
Afrxzo
(AFRXOGUNS)
March 22, 2021, 9:52pm
#8
Yes, make sure this is in a module script too!
Nkk2356
(Nkk2356)
March 22, 2021, 9:52pm
#9
Ik! I already put it in a module before I posted this topic. Don’t worry