I kind of have a hard time understanding what the point of an :Init() function in a singular script architecture is, like whats a realistic scenario where you would need to wait for something before starting a module script? I kinda just dont really get it, why not just do all that waiting/initializing stuff in the actual :Start() function of the module?? Whats the purpose of breaking a start-up of a module into two separate functions, is it just how some people like to do it that way?
I mean you don’t even have to have one, the start function could be the Init function and vice versa, or you could have both. Pretty sure it’s an organization thing ![]()
An init function is usually used to start modules which connects to regularly-updated events (like PreRender or InputBegan) so modules can be started later after requiring, preventing errors when the other modules, maps, or other dependencies haven’t loaded yet. This usage is typically found in lighting modules, simulation modules, etc..
Another use case would be to track the script that required it by adding an origin script parameter to the init function. I’ve seen it used as a roadblock for exploiters so it takes more steps to tinker with the client-side of things.
Also, the init function can return more than one values, sidestepping the limitations of module requirement needing to return exactly one value.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.