I’m making a plugin for notes, and I want them to save through plugin:SetSetting() and plugin:GetSetting() how would I do this?
Heres what I have already, it doesnt work:
Save.MouseButton1Up:Connect(function()
local CurrentTextboxText = ""
plugin:GetSetting(CurrentTextboxText)
plugin:SetSetting(CurrentTextboxText, true)
Saved.Visible = true
task.wait(5)
Saved.Visible = false
end)
Load.MouseButton1Up:Connect(function()
local CurrentTextboxText = ""
local Save = plugin:GetSetting(CurrentTextboxText)
if Save then
TextBox.Text = CurrentTextboxText
end
end)
function plugin:SetSetting(string Key, variant value)
-- Set a setting using a key and set the value of the key in the second argument
function plugin:GetSetting(string Key)
-- Retreive a plugin setting value from the requested key
From the looks of it, you’re setting the Key for the plugin setting as the user’s text, which is a bad idea considering many different keys will be created because the text may not always be the same.
You should be doing this:
Save.MouseButton1Up:Connect(function()
local CurrentTextboxText = "" -- Set this as the user's text
plugin:SetSetting("UserNotes", CurrentTextboxText) -- the key is "UserNotes" and the value are the notes itself
Saved.Visible = true
task.wait(5)
Saved.Visible = false
end)
Load.MouseButton1Up:Connect(function()
local Save = plugin:GetSetting("UserNotes") -- get the user's notes from the key
TextBox.Text = Save or "" -- if the user saved something before, load it, if not, then leave it blank
end)