Im aware its short for initialize, but I see this in many tutorials without them explaining it. Whats supposed to be inside the init function and what instance would you call it?
function module.init()
-- Whats supposed to be written in here?
end;
Im aware its short for initialize, but I see this in many tutorials without them explaining it. Whats supposed to be inside the init function and what instance would you call it?
function module.init()
-- Whats supposed to be written in here?
end;
I think its just something developers use to show what function fires first, although I am as confused as you, a quick google search showed me:
Read this.
ModuleScripts General queries? - Help and Feedback / Scripting Support - DevForum | Roblox
Init is short for initialize. If anything needs to be set up when loading the module (or more likely when creating a class) you will call the init method.
Init
is just a function like any other. Usually if it’s named that, it’s because it should be called exactly once to perform some kind of setup the module needs.
It is also usually unnecessary, since any initialization code can just go at the top level of the module, meaning it will run once and only once (per client/server) when require()
d.
This init pattern is usually for what should be fired first to “get something up to be ready”. It’s only called once, and usually all different initializing functions are wrapped into a single function(or at least called in orders or not depending the necessities) in industrial practices.
Notable changes from using the initialization include, in the case of Roblox, creating folders necessary for different purposes and changing global parameters on the experience’s behavior.