How can I add plugin "types" to modulescripts

image
that doesn’t autofill but I want it to autofill and I want to be able to do pluginToolbar and properties like that. Same for everything else. Can modules have a plugin runcontext?

1 Like

So the thing about modules is they do not have access to the plugin value by default. You’d have to pass the plugin value to said module.

if you want it to appear in autocomplete you’d have to also define it as a value, what I do personally is this:

local plugin:plugin
local module = {}

module.setup = function(PluginObject)
    plugin = PluginObject
end

return module

it doesnt need to be exactly like that, but something similar still gets the job done!

so I tried that and I did this

local plugin:plugin
local module = {}

module.Initialize = function(PluginObject)
	plugin = PluginObject
end
module.CreateButton = function()
	plugin:create
end


return module

though nothing that is a function of plugin is autofilling still since :plugin is not a type in none plugin context scripts

1 Like

I see that now, I think roblox might have changed it cause I remember :plugin being a type I could use, that or my memory is bad.

In that case I dont think theres anything you can do to autofill the properties and functions of plugin, but at least the autofill shows the plugin variable now!

1 Like

well it’s sad I can’t change a module’s runcontext (I get it’s a module so it can’t support that as well but atleast give me access to plugin variables if I want), thanks for the help

1 Like
local plugin: Plugin = script:FindFirstAncestorWhichIsA("Plugin")
1 Like

even this doesn’t work

which is surprising

Plugin is a type, try that, like:

local plugin: Plugin

module = {}

function module.setup(reference)
	plugin = reference
end

function module.button()
	-- should have autocomplete for plugin here
end

return module

this doens’t work either, for some reason it’s so sensititive about plugin

1 Like

thinking about it now, it might be cause of the new type solver, I havent messed with this stuff in a while, but I know when I did it wasnt enabled. Are you using it? That or its the Incremental typechcking and autocompletion

1 Like

I actually disabled that because of how bad it was, I just checked and it is still disabled so that isn’t the problem

1 Like

Try enabling the “Autocomplete Plugin-security methods” setting.


2 Likes

oh wow I didn’t know it was in settings or even feature at all

1 Like