local moduleTemplate = require(script.ModuleTemplate)
local scriptTemplate = require(script.ScriptTemplate)
local localTemplate = require(script.LocalTemplate)
local moduleDefaultLength = 22
local scriptDefaultLength = 22
local localDefaultLength = 22
local desirables = {"Script", "LocalScript", "ModuleScript"}
local scriptEditor = game:GetService("ScriptEditorService")
game.DescendantAdded:Connect(function(obj)
if table.find(desirables, obj.ClassName) then
local source = scriptEditor:GetEditorSource(obj)
local length = string.len(source)
if obj:IsA("Script") and length >= scriptDefaultLength then
scriptEditor:UpdateSourceAsync(obj, scriptTemplate)
elseif obj:IsA("ModuleScript") and length >= scriptDefaultLength then
scriptEditor:UpdateSourceAsync(obj, moduleTemplate)
elseif obj:IsA("LocalScript") and length >= localDefaultLength then
scriptEditor:UpdateSourceAsync(obj, localDefaultLength)
end
end
end)