Roblox doesnt include “plugin” in the global library of a module script. However whenever I try to define it in an attempt to get around this, roblox flags it because its “built in globally”. See screenshot below.
I could just call the variable something else, and that would fix this problem. What I really need to know is if roblox did this for a reason. Is there a downside to using a module script when making a plugin that I am not aware of?
Roblox just does that when you name a variable the same thing as a global keyword. It won’t throw an error, but it’ll just leave an ugly underline under it.
local TimeSaverRenamer = {}
function TimeSaverRenamer:InitiatePlugin()
print("MODULE SCRIPT PLUGIN WORK 100 %")
-- Create a toolbar for the plugin
local toolbar = plugin:CreateToolbar("TimeSaverRenamer")
-- Create button
local button = toolbar:CreateButton("Open TimeSaverRenamer", "Opens the Time saver Renamer", "rbxassetid://1234567")
local isActive = false
-- Button click event handler
button.Click:Connect(function()
isActive = not isActive
if isActive then
print("MODULE SCRIPT PLUGIN WORK 100 %")
button:SetActive(true)
else
print("MODULE SCRIPT PLUGIN WORK 100 %")
button:SetActive(false)
end
end)
end
return TimeSaverRenamer
local PluginContext = {}
function PluginContext:Initialize(plugin)
self.plugin = plugin
end
return PluginContext
Main ServerScript:
local RunService = game:GetService("RunService")
local PluginContext = require(script.Parent.PluginContext)
if plugin then
if not RunService:IsEdit() then
return
end
PluginContext:Initialize(plugin)
-- ...
end
Then anytime I need the plugin variable, I can just require PluginContext and use it from there
That’s weird maybe it’s because Roblox detect that I made a module script hence he definitely says it’s not a plugin script because I’m using another module but this explanation wouldn’t make sense honestly
I usually have a folder with all my scripts. I right click the folder and click ‘Save as Local Plugin…’. After the explorer dialog pops up, I just overwrite my previous saved plugin. Studio unloads and reloads the plugin for me.