What should Roblox Studio plugins use for persistent storage?

169 views Asked by At

For Studio plugins that want to save user preferences, where should that data be saved?

Let's say for example, I have a list of toggle switches, and I want to save what the user has toggled on and off. Where should that go? Is there a place to store data that persists across DataModel sessions? The plugin documentation and tutorials don't cover this use case.

DataStores don't seem to be the right place as they are on a "per-experience" basis, require explicit permission to work in Studio, and are a security risk to expose for a plugin that doesn't care about a user's game data.

I've never used LocalStorageService, but the name implies that it might be the right place, but the docs are currently just a skeleton.

Is there a way to store any data with a plugin?

1

There are 1 answers

0
Kylaaa On BEST ANSWER

The plugin object has a function called SetSetting that allows you to store information in the plugin itself. According to the docs :

Stores a given value for later use under the given key. The value will persist even after studio is closed.

You can retrieve this data using the GetSetting function.

local plugin = script:FindFirstAncestorOfClass("Plugin")

local key = "foo"
local defaultValue = 0

-- check if anything has been stored already
local existingValue = plugin:GetSetting(key)
if not existingValue then
    -- if not, store the value for later
    plugin:SetSetting(key, defaultValue)
    existingValue = defaultValue
end

print(existingValue)