Before you can jump into creating an addon; there's a few things you need to know.
How to properly unload your addon
Lua is limited and because of this we are required to have a few tedious steps to ensure proper unloading.
You must connect to a signal that fires when an addon is unloaded, this signal is fired with one argument, that being the file name of the addon.
The purpose for this is so you can properly disconnect connections, remove drawing objects and anything that may linger after your addon's thread is stopped.
Example
-- // File name is "spam.lua"local connections = {}local drawings = {}localfunctionnewConnection(signal,callback)local connection = signal:Connect(callback) connections[#connections+1] = connectionreturn connectionendlocalfunctionnewDrawing(class,properties)local object = Drawing.new(class)for property, value in properties do object[property] = valueend drawings[#drawings+1] = objectreturn objectendnewConnection(game:GetService("RunService").Heartbeat, function(dt)print(dt)end)dolocal viewport_size = workspace.CurrentCamera.ViewportSizenewDrawing("Square", { Visible =true; Transparency =0.5; Size = viewport_size/2; Position = viewport_size/4; Color = Color3.fromRGB(255,255,255) })endnewConnection(juju.script_unloaded, function(key) -- the juju table is global!if key =="spam" thenfor _, connection in connections do connection:Disconnect()endfor _, drawing in drawings do drawing:Destroy()endendend)