#How does the module script work?
1 messages · Page 1 of 1 (latest)
which module script
So a module script is a script that can be accessed throughout any other script (local and server). A module script is one global table so you can add anything in it. So to add a dictionary amount, here's an example script ( gimme one sec)
local module = {}
module.Sword = {
Price = 100,
Name = "Sword",
Level = 1
}
module.SayHello = function()
print("Hello!")
end
return module
so, the first thing, module.Sword
it is equaled to a table and i can add anything in it!
and the second one, i made it a function!
so now, if i pull up a server script
local module = require(game.ServerScriptService:WaitForChild("ModuleScript"))
print(" The sword costs "..module.Sword.Price.." coins!")
this is in a serverscript
i called the module script using require
it modules
and i accessed the price of the sword!

💀
so in short, it stores information that can be accessed through server and local scripts!
sorry 😭😭
thx!
a module script is a script that lets u acess/storedata if u wana use it for that if u do the thing Laughingboxes showed u it will store data but the mudle.sayhello is kinda structured in his own way what i would do is
local Self = {}
function Self.PrintHello()
print("hello")
end
--or
function Self.PrintMessage(Message)
print(Message)
end
return Self
** You are now Level 3! **
@alpine jolt
also how u call it is by doing local Module = require(ur module location.moduleName), how i would is local Module = Require(game.ReplicatedStorage.MyModule)
@alpine jolt
its really just a storage of values that you can get anything
*anytime
using the require(modulename) function
not just that u need the directiry
Thank you so much to everyone who explained how it works
