Script.source doesnt update correctly

Look:

I ran

workspace.Script.Source = "ROBLOX "

in command bar. It is very janky and sometimes doesnt work at all. When it does work it doesnt update in real time.

I uninstalled roblox to see if redownloadiong work work. No it doesnt
I restarted my pc. No it doesnt work still

Here is a video

You need to use ScriptEditorService:UpdateSourceAsync instead ScriptEditorService | Documentation - Roblox Creator Hub

1 Like
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)

I don’t think I am using

scriptEditor:UpdateSourceAsync() correct.

How do I use it

scriptEditor:UpdateSourceAsync(obj, function()
	return scriptTemplate
end)

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