Unable to assign property Source. ProtectedString expected, got string

Im trying to make a plugin that turns the object you have selected into lua code, everything is working as intended but when i try to convert a larger model it just prints this error
“Unable to assign property Source. ProtectedString expected, got string”

function fixString(str)
	return str:gsub("[%p%c%s]","")
end
function convert()
	local model = selection:Get()
	if #model > 1 then warn("Please select one model at a time.") return else model = model[1] end
	local Script = Instance.new("Script",model.Parent)
	local instanceCount = 0
	local fixedName = fixString(model.Name)
	ch:SetWaypoint("Added new script")
	local convertedProperties = ConvertInstance(model,instanceCount)
	local Source = "--"..model.Name.."--\n\nlocal "..fixedName.."_"..instanceCount.." = Instance.new(\""..model.ClassName.."\")"
	for i,v in pairs(convertedProperties) do
		Source = Source.."\n"..fixedName.."_"..instanceCount.."."..tostring(v)
	end
	instanceCount += 1
	if #model:GetDescendants() > 0 then
		for i,dec in pairs(model:GetDescendants()) do
			if props[dec.ClassName] then
				fixedName = fixString(dec.Name)
				Source = Source.."\n\n--"..dec.Name.."--\n\nlocal "..fixedName.."_"..instanceCount.." = Instance.new(\""..dec.ClassName.."\")"
				local convertedProperties = ConvertInstance(dec,instanceCount)
				for i,c in pairs(convertedProperties) do
					Source = Source.."\n"..fixedName.."_"..instanceCount.."."..tostring(c)
				end
				instanceCount += 1
			end
		end
	end
	table.clear(convertedInstances)
	Script.Source = Source
	Script.Name = model.Name.." to lua"
end
button.Click:Connect(convert)

I think the problem could be in there but if u need to know more just let me know

Fixed it by putting all the parts in a table, i dont know what the problem was but it worked

never mind its happening again

Did you ever find a solution? Having the exact same issue.

1 Like

Just got this issue with a plugin I was using. Worked last night, and now it won’t write to scripts anymore.

1 Like

This completely broke my map builder. I can no longer develop my game if roblox decides to block this feature.

1 Like

What happened? We cannot write code into module scripts from console anymore?

Yh seems there is a character limit for using it idk why.

3 Likes

Wrong, it appears that this string contains unrecognizable characters, therefore Roblox cannot read it and prompts an error

1 Like

Hello, did anyone ever find a fix to this? If so, what was it?

sorry im late but I’ll try this when i get home and see of that fixes it and mark your reply as a solution

doesn’t seem to be the problem sorry.

not sorry to bump but,

has anyone figured out a solution to this?

it’s defiantly not unrecognizable characters as I tested that and the only one that causes a problem is null (which just ends the string early)

additionally, my string is only in hexadecimal which are not control characters

thanks

I’ve finally figured out the issue for those who are interested,

This apparently comes out when the length of the source > 199999
(which the message doesn’t imply at all)

If anybody needs code to make the source files and split the source here is some:

source = string.rep("e", 1025392)
print("Creating source file, source length " .. #source)
	
if #source < 200000 then
	local sourcefile = Instance.new("Script", script)
	sourcefile.Source = source
	sourcefile.Name = "Source"
		
	print("Source file created :", sourcefile)
else
	print("Source is >= 200000 characters, resault will have to be split")
	local sources = {}
		
	local p = 1
	local c = 1
	repeat
		local sourcefile = Instance.new("Script", script)
		sourcefile.Source = source:sub(p,p+199998)
		sourcefile.Name = "Source" .. c
			
		table.insert(sources, sourcefile)
		p += 199999
		c += 1
	until p > #source
		
	print("Source files created :", table.unpack(sources))
end
11 Likes