Why do all plugins share a global table of settings?

I put essentially this in a local plugin:

print(plugin:GetSetting("1"))

if not plugin:GetSetting("1") then
    plugin:SetSetting("1", true)
end

The first run obviously prints nil and then sets the key to true. When I re-save the plugin, this time it prints true. I expected it to print nil because it’s a new plugin and shouldn’t have any settings. Then I opened a new place file, and it still printed true despite the plugin running in a different place.

Hence my question: Why do all plugins share a global table of settings?

Plugins can easily overwrite each other’s settings and it’s a hassle to set per-place settings.

2 Likes

You can use unique keys to prevent collisions with other plugins; An easy solution is to precede keys with the plugin’s name. Per-place settings can just be stored in the DataModel (ServerStorage or ReplicatedStorage) if you aren’t afraid of ChangeHistoryService changing your values on undo/redo.

Storing data in ServerStorage and ReplicatedStorage defeats the purpose of having plugin storage. Is there no other better way? Do place files have some sort of unique ID?

Installed plugins do not have this problem because their settings are scoped to their assetId. This issue only happens for development plugins (.rbxm files in the Plugins folder).

4 Likes

I think game.Name outputs the place file’s name, but that’s not the best solution.