API:Class/Plugin/SetSetting

SetSetting

PluginSecurity: This member cannot be used in scripts, but is usable in the command bar and plugins.
Function of Plugin.pngPlugin
void SetSetting (
    string key,
    Variant value
)
Parameters:
  1. key
  2. value

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

Notes

  • This item is protected. Attempting to use it in a Script or LocalScript will cause an error.
  • The chosen key only needs to be unique per plugin and cannot be an instance or a Lua function.
  • SetSetting only saves maps of String -> Variant - if you try to save an array to it, the indices will be converted to strings to conform to the String -> Variant format.

Example

The below example would save the value of the key "FirstTime" as false. This could be useful in plugins which provide the user with a tutorial of it's use.

local Plugin = PluginManager():CreatePlugin()
local RanBefore = Plugin:GetSetting("RanBefore")
Plugin:SetSetting("RanBefore", true)
 
if RanBefore then
	print("Welcome back!")
else
	print("Welcome! Thanks for installing this plugin!")
end