Attempt to index nil with 'SetSetting' , which makes plugin somehow nil?

Hello DevForum!

I normally understand indexing a nil errors, like with values and other stuff, but this one doesn’t make quite sense.

  07:26:26.105 attempt to index nil with 'SetSetting'  -  Studio - install:68
  07:26:26.105  Stack Begin  -  Studio
  07:26:26.105  Script '', Line 68  -  Studio - install:68
  07:26:26.106  Script '', Line 40  -  Studio - glass:40
  07:26:26.106  Script 'user_lua.console.rbxmx.lua.console.PluginManager', Line 116  -  Studio - PluginManager:116

Is my error, but the weird thing is the exact line where it happens, it seems that plugin is somehow nil?

-- Setting the save table

local jsonSave = http:JSONEncode(save)
plugin:SetSetting("Installed", jsonSave) -- Error line

The script is in a module script, so is it a thing that you can’t call :SetSetting() from a module script/not main script?

This installer script has been giving me a lot of trouble, as you may have seen by my other recent posts, but any help would be greatly appreciated!

plugin can only be called from a Script (I believe).


1 Like

plugin can still be called from LocalScripts, I tried myself


Only the script that has been executed as a plugin can use plugin, that’s why it’s nil in their descendants.


Adding on to the @WhitexHat, I imagine you can pass plugin as a parameter to your module’s functions for actions like this.

1 Like

Ohh, ok thanks!
Didn’t know that, but yeah I’ll pass it as a parem.

Why would you need to use plugin in a module? plugin is specifically for functions plugins have that modules don’t. Anything you would be able to use in a module already exists hence why plugin exists.

Uhhh, for a command handler? I am currently making a package manager and not breaking up the main script would make it almost impossible to traverse and read. Also, it’s very easy to to make new commands very quickly.

1 Like

Special case, but it would have to have a completely different keyword with some things removed and some added. I don’t think it is worth the effort for a few functions.

Few? The plan is to have a large amount, modern consoles have large amounts of commands, obviously, I won’t have as much but it’s better to have the option of expandability in my case.