As a Roblox developer, it is currently impossible to retrieve the Plugin from ModuleScripts using the plugin
global. This is because ModuleScripts under a plugin dont have the global set.
This makes developing modules for plugins that need features from the plugin difficult since we need to rely on wokarounds to retrieve the plugin object which looks messy when reading over code.
Pass in the Plugin
handle using a function as such: (The “clean” workaround)
local Plugin
return function(PluginHandle)
Plugin = PluginHandle
end
Or, use FindFirstAncestoryOfClass or similar member to find the Plugin object.
The issue with the first method is that I need to return and call a function when requiring in a module just to set the Plugin handle in the ModuleScript.
local ModuleThatUsesPlugin = require(script.Module)
-- looks cleaner and performs better than
local ModuleThatUsesPlugin = require(script.Module)(plugin)
The issue with the other method is that FindFirstAncestor isn’t a cheap method when being called in every single module, this method could also break if Roblox changes how code inside Plugins are structured (doubt it since this would make PluginDebugService harder)
If Roblox is able to address this issue, it would improve my development experience because I would be able to work with the Plugin without having to rely on hacky workarounds.