Blank Script Plugin "Broken"

I wrote a plugin script years back that will automatically blank newly added scripts:

game.DescendantAdded:Connect(function(o)
	pcall(function()
		if o:IsA('BaseScript') or o:IsA('ModuleScript') then
			if o.Source == 'print("Hello world!")\n' or o.Source == 'local module = {}\n\nreturn module\n' then
				o.Source = ''
			end
		end
	end)
end)

I’ve noticed recently that it hasn’t been working. After some experimenting, I realized that the plugin actually was working, but the script editor wasn’t updating. It has come to my attention that no source edits to a script will update the script editor visually while it’s open (the edits will still be made, but you won’t see the changes in the opened script editor).

This definitely wasn’t the case before and I’m wondering what has changed to cause this behavior, and more importantly, how I would get around this to fix my plugin?

1 Like

Alright, I’ve learned that this was caused by this particular update:

UpdateSourceAsync is needed now for plugins like this. If anyone would like, here’s the updated script:

local scriptEditorService = game:GetService('ScriptEditorService')
game.DescendantAdded:Connect(function(code)
	pcall(function()
	if code:IsA('BaseScript') or code:IsA('ModuleScript') then
		scriptEditorService:UpdateSourceAsync(code,function(source)
			if source == 'print("Hello world!")\n' or source == 'local module = {}\n\nreturn module\n' then
				return ''
			end
		end)
	end
	code = nil
	end)
end)

I’m sure this has been made before, especially after the update, but I’ve also uploaded it has a free plugin that I will keep up-to-date if anything breaks *(though I doubt it will at this point):

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.