Trying to make a module for both client and server.
My plan is to call it massive module.
I want the module to have a lot of functions that are very hard to right
Here’s what I did in a day
--[[ MassiveModule
HOW TO REQUIRE MODULE:
(they are diffrent for client and server)
PLEASE copy and paste them
Client:
local mod=require(script.Parent:WaitForChild("MassiveModule")).Client()
Server:
local mod=require(script.Parent:WaitForChild("MassiveModule")).Server()
]]
--<< MODULE >>--
local program=script:WaitForChild("Program")
local storage=program:WaitForChild("Storage")
local s={}
s.Run=game:GetService("RunService")
s.Players=game:GetService("Players")
local isClient,isServer,isStudio=s.Run:IsClient(),s.Run:IsServer(),s.Run:IsStudio()
local plr;if(isClient)then plr=s.Players.LocalPlayer end
local modServer,modClient={},{}
--<< MODULE FUNCTIONS >>--
-- --[[]]mod.=function()end
print()
local module={--
--MassiveModule Server Require Function
["Server"]=function()
if(isServer)then
return(modServer)
else return;end
end,
--MassiveModule Client Require Function
["Client"]=function()
if(isClient)then
return(modClient)
else return;end
end,
}
return(module)
Ideas on what functionsI should add here?
Tell me stuff like average (or even advanced) scripters don’t know how to code or takes too long to write it.
So basically, Im trying to make a module that has a lot of stuff that will be named MassiveModule
And asking average scripters to know what they don’t know how to code OR takes too long to write the code.
(give me some details/lines of code if its too complicated)
This aproach seems very bad, it not only makes your code centralised and unorganized, but also adds unnecesary complexity to it and makes refactoring required
Try to write more modules, you can follow principles like Never nesting or You ain’t gonna need that, but also keep in mind a module should:
Contain only functions related to it (Timer Module should only have timer’s functions)
Have name that tells what it does
Store data only related to it (Similar to functions)
Optional, but you should separate data module from function ones
Thanks for your reply!
I never made a module so I didn’t know it.
Would this be better?
There will me a mainModule and inside it, there will be a folder named modules and there will be a alot of modules.
This is what the code looks like:
local modules:Folder=script:WaitForChild("Modules")
return({
["ServerModules"]={
["ModName"]= require(modules.TestModScript) ,-- Module 1 for Server
},
["ClientModules"]={
["ModName"]= require(modules.TestModScript) ,-- Module 2 for Client
},
})
This is what workspace looks like
(click the arrows like its the real workspace)
Yk, you shouldn’t use server sided modules in replicated areas, it’s unnecesary replication and anyways if it’s server module it can be accesed only by server, only shared modules should be stored in Replicated Storage (usually some data like tool stats or names ect.)
Another tip is to use space to separate math symbols, i see you don’t do that, and it’s more redable when those symbols are separarted, if you like this kind of syntax and can use it without problems you can stick to it
I don’t usally put spaces, script:WaitForChild "InstanceName" doesn’t feel right to me
also, I also code javascript. and in javascript, this doesn’t work:
if true {
//some code
}
But this works
if (true) {
//some code
}
And, I just like it like local trueValue,falseValue=true,false
Not
local trueValue = true
local falsevalue = false
Plus, both code works the same
How about this
--[[ Massive Module
HOW TO REQUIRE MODULE
SERVER
local mod=require(game:GetService("Workspace"):WaitForChild("MassiveModule")).ServerModules
CLIENT
local mod=require(game:GetService("Workspace"):WaitForChild("MassiveModule")).ClientModules
]]
-- ["ModName"]= require(ModScript) ,--
local modules=script:WaitForChild("Modules")
return({
["ServerModules"]=modules:WaitForChild("Server"),
["ClientModules"]=modules:WaitForChild("Client"),
})