Hi,
can someone help me with this?
local module = {enabled = false}
module.__index = module
function module:CreateToolBar(toolbarName)
local newToolbar = setmetatable({}, module)
local Toolbar = plugin:CreateToolbar(toolbarName)
newToolbar.Toolbar = Toolbar
return newToolbar
end
That´t the error:
19:16:19.131 - user_ModuleTest.rbxmx.PluginModuleTest.PluginCreator:7: attempt to index nil with 'CreateToolbar'
19:16:19.132 - Stack Begin
19:16:19.132 - Script 'user_ModuleTest.rbxmx.PluginModuleTest.PluginCreator', Line 7 - function CreateToolBar
19:16:19.132 - Script 'user_ModuleTest.rbxmx.PluginModuleTest.Script', Line 3
19:16:19.132 - Stack End
Full ModuleScript
local module = {enabled = false}
module.__index = module
function module:CreateToolBar(toolbarName)
local newToolbar = setmetatable({}, module)
local Toolbar = plugin:CreateToolbar(toolbarName)
newToolbar.Toolbar = Toolbar
return newToolbar
end
--== AddButton ==--
function module:AddButton(name, tooltip, iconId, UI)
local isopen = false
local button = self.Toolbar:CreateButton(name, tooltip, iconId)
local guiSettings
--== Loop Through Children ==--
for i, mainUI in pairs(UI:GetChildren()) do
--== Error if too many children ==--
if #UI:GetChildren() > 1 then
error("PluginCreator: Only 1 Frame in UI! The Frame in the UI will give the <DockWidgetPLuginGui> the Main Size!")
else
--== Create DockWidgetPluginUi ==--
guiSettings = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Left,
module.enabled, -- Widget will be initially enabled
true, -- Don't override the previous enabled state
mainUI.Size.X, -- Default width of the floating window
mainUI.Size.Y, -- Default height of the floating window
50, -- Minimum width of the floating window (optional)
50 -- Minimum height of the floating window (optional)
)
end
local interface = plugin:CreateDockWidgetPluginGui(
name, guiSettings
)
UI.Parent = interface
button.Click:Connect(function()
isopen = not isopen
module.enabled = isopen
button:SetActive(isopen)
return UI
end)
end
end
return module
I’m trying to create a module to easily create a Plugin easily. Module is with Advanced OOP.
Hope someone can help me!
Thanks