If you making a plugin and have some problems with plugin settings or just want to learn how to do it, you’re at the right place.
When we create a plugin maybe we have some data to save, if you doing it the first time, maybe you will think first of DataStoreSerivice. You’re almost at the right place. The plugins have a little bit different storage that stores files not on the Roblox servers, but inside of a file on your computer.
So instead of DataStoreSerivice it’s better to use
plugin:SetSetting - to save data
and
plugin:GetSetting - to get data
it works almost the same. To use it, you do
plugin:SetSetting(--[[name]], --[[data]])
name - string
data - table | string
and to get the data plugin:GetSetting(–[[name]])
Now about the possible errors.
First, if you see the message
There can be 2 reasons for that
- You are using plugin inside of the ModuleScript
They dont have direct access to this so you have to set in manually with a function
e.g
Script:
local module = require(Module)
module.SetPlugin(plugin)
ModuleScript
local plugin
--Passing the plugin through the function
function module.SetPlugin(_plugin: Plugin)
plugin = _plugin
end
- You are using the plugin in regular scripts
only the scripts in the plugin can access plugin, and not in-game scripts
Other possible error:
That means something happened on the way of saving.
If you fail to save/get data once it will restrict any other attempts to Get/Set and you’ll have to restart the plugin.
But why can it fail?
- You attempting to save non-supported types
like
"Instance" | "CFrame" | "Vector3" | "EnumItem" | "Color3" | "UDim" | "ColorSequence" |
"NumberSequence" | "UDim2" | "BrickColor" | "Vector2" | "Font" | "NumberRange" |
"Axes" | "Rect" | "Ray" | "Faces"
as well the error can be “failed to convert type to std::string”
sad news, you have to handle that by yourself, the best way you can do it is with a buffer.
Especially “Instance” cannot be saved because it’s a reference to an object in place (like an address of an Instance), not the object itself.
- You attempting to save the binary data
The plugin does not support it because it encodes the data in JSON, so you have to convert it to base64
Hopefully, it can help you when you create your plugin