I have no idea what you mean. Explain it in a more noobs language.
The instance isnāt changed. You can have it so when you require your ModuleScript, the actual structure it returns (like a table) has the events and such.
ā¦ maybe in Bacon-Hair language. I still donāt understand fully. Do you mean you canāt automatically change it like a intsance because you only (get) functions, variables, etc?
The module script itself is an object, instance, whatever you wanna call it. When you use the require keyword on the module script, you have access to the stuff inside of the module script that you returned.
ex)
ModuleScript located in game.ServerStorage and named āModuleā:
local module = {
["Key"] = "Value"
}
return module
Script located in ServerScriptService:
local randomModule = require(game.ServerStorage.Module)
print(randomModule["Key"])
>> Value
Windows Shuting Down I knew the module was a instance but I ment can you have your own custom Events functions and variables, while using required of course.
You can have all that in a table that you return inside the ModuleScript, but not on the actual ModuleScript instance itself.
Example:
-- ModuleScript.lua in Workspace
local mod = {}
mod.basicBool = true
mod.basicFunc = function()
end)
return mod -- The data returned here and HERE only is sent back as the result of the require()
-- SERVER.LUA in ServerScriptService
-- The following is the module INSTANCE.
-- It has all the generic properties, functions,
-- and events in it such as Instance.Name,
-- Instance:Destroy(), and Instance.Changed.
local moduleInstance = workspace.ModuleScript
-- The next is different. When require()ing the module,
-- I am essentially running the code inside, and asking
-- for whatever that return statement earlier returns
local moduleData = require(moduleInstance)
-- The moduleData variable does not have any of the stock Instance
-- functions, properties, or events built in because it isn't an Instance.
-- It is technically a lua table (thats what the {} mean) containing one
-- variable (basicBool) and one function (basicFunc). If you want to
-- destroy the module Instance itself, moduleData does not have a
-- Destroy() function. You would have to call Destroy() on the INSTANCE.
I understand that if you make a function inside a module you canāt go Module Script:myfunction. But what I ment was itās similar because you can fire the functions and events inside it.
Events are RBXScriptConnection objects. They technically cannot be created by standard code. If you mean BindableEvent objects, then yeah.
I find many ways I can use them but my game is filtering enabled so I canāt make a local one
Any ModuleScripts required from the client are treated as local.
in the client not required from a client script, right?
Required from the client.
Wait you mean if a module script is called from a local scripted it will work as a local module?
Yes.
Thatās great!