I tried making a plugin, and I keep getting annoying errors from old versions of the plugin
This is the main script:
local core = game:GetService("CoreGui")
local guiF = script.Parent.Parent.Gui
local toolbar = plugin:CreateToolbar("RGB Suite")
local button = toolbar:CreateButton("Open suite", "RGB Suite V0.1", "")
local open = false
script.Parent.Parent.Parent = game.ServerStorage
function on()
local gui = core:FindFirstChild("RGBSuite")
gui.Enabled = true
end
function off()
local gui = core:FindFirstChild("RGBSuite")
gui.Enabled = false
end
if not core:FindFirstChild("RGBSuite") then
local cgui = guiF:FindFirstChild("RGBSuite"):Clone()
cgui.Parent = core
open = false
end
local function clicked()
if open == false then
on()
open = true
button:SetActive(true)
else
off()
open = false
button:SetActive(false)
end
end
button.Click:Connect(clicked)
plugin.Unloading:Connect(function()
button:SetActive(false)
plugin:Deactivate()
core:FindFirstChild("RGBSuite"):Destroy()
script.Parent.Parent:Destroy()
end)
The gui itself does get refreshed, but other scripts in the plugin keep erroring because they didnt get removed properly, even though I destroyed the whole plugin folder.
Cleaning up plugins is not explained anywhere, even in the “Intro to plugins” article, so now Im just stuck on what to do about this
How can I solve this?
Observation 1: if the main script parents the whole plugin folder to ServerStorage, it DOES get destroyed when it unloads, but the TextEditor still runs somehow even though its destroyed?
Observation 2: plugin.Unloading doesnt fire when the place closes for some reason
The error comes from my RichText editor thats in the plugin, its in a widget.
If you select a TextBox or other gui element with text, the script checks if it has RichText checked or unchecked.
If its unchecked, it makes a “Error” Label visible.
This is where the problem comes from, the script works properly, and the label DOES get shown or hidden, but the old code still errors.
It says “Error” is not a valid member of TextBox or infinite yields possible
I can confirm its old code, since the currect script is named “TextEditor”. If I rename it to something else, “TextEditor” would still give errors
Actually, does this happen only for plugins that are saved locally?
I didnt publish this plugin to Roblox, so I dont know if this happens ONLY to saved locally or all plugins
If you dont need the old script just delete it or disable it, do you need that?
I don’t understand why you need to have an old script if you have a new one that does the same functions
If I overwrite the plugin file (when I update the plugin) the old versions of the code still run until I restart studio.
Even if I destroy or disable the old scripts, they still run
I found a basic fix for this, I just did an if statement in most functions: if script.Parent ~= nil then
And it seems to eliminate the errors, but I dont know if the old script versions still remain somewhere out there, and I dont know what to do with it
oh.
I don’t know what to do with the old versions but you can put a version control, a code that downloads the version number from a pastebin page (or an online database) and checks if it is not the same as the version in use, disabling the plugin
So when you update it just change the new version number in the pastebin page and in the new script to disable the old versions
something like:
local pluginVersion = 1 -- current plugin version
local newVersion = -- download from the pastebin page with Http service
if pluginVersion == tonumber(newVersion) then
-- Execute the code
else
print("Update the plugin")
end