String too long - Trying to edit source of script


Describe the bug

When trying to edit the source of a script via a plugin, it errors with “String too long”


Reproduction: (A plugin script)

local s = string.rep("OOF", 100000)

local thing ="Script", workspace)
thing.Source = s

Why is this a problematic bug?

Currently developing a git integration plugin, and it requires modifying the source of the scripts to change to newer versions, and prepend git related data at the top of the script, and phantom forces has really large singular scripts, which this bug conflicts with.

The length of the script I am trying to modify has a string length of 300,000+ characters, and it seems the limit is about 200,000.


I’ve actually run into this issue before while trying to obfuscate or otherwise manipulate the source of a script, and having the limit raised would be helpful for my purposes. That being said, some testing shows me that 199,999 is a hard limit in all string properties.

I ran this code to test the max length of strings:

Be wary of running this because it’s going to take a long time because it’s not meant for speed.

local Script ="Script")
local rep = string.rep
local pcall = pcall

local function Set(i)
	Script.Source = rep("-", i)

for i = 1, 2^32 do
	if not pcall(Set, i) then
		print(i-1) -- To get an accurate value

And got:


I did the same thing but with the Value property of a StringValue and got:


With the name of a StringValue:


This makes me think this is an intentional limit and not a bug, but regardless it should be raised.

1 Like

The limit has been 200k for many months now. It’s a problem for my obfuscation and my place statistics parser too. I just have to work around it and create a new script instances and stitch it together by hand.

1 Like

I’ve looked into it in my own time, when you set the string of a script it makes it into a “ProtectedString” in the instance bridge of roblox. but in that process it calls “throwable_lua_tostring” a C function in the engine with a hardcoded size limit, which it seems that function was made for a past issue dealing with networking limitations.
That issue seems like it is no longer a issue that applies to the “ProtectedString” though, due to the fact they don’t send the source anymore. Instead they just send the bytecode rather then replicating the whole protected string.
I’d imagine using define macros it can be made a exception for studio for setting a “ProtectedString” on a script or just rather remove this functionality for setting a “ProtectedString” via lua in the end.


These network limitations may still apply in team create, but I’m pretty sure you can still paste strings longer than 200k (you just can’t manually set .Source from a script). I’ve worked on many projects that involve processing lots of data or auto-generating source, and this limitation is always frustrating.

1 Like

Good point, I disassembled the latest roblox version regarding serializing these strings rather then going off of old stuff. The actively used max payload size per a string can be found in the client flags. which is currently 96000000 bytes, judging by the size I think they overcame this limitation. But if they didn’t it would be nice to make the limit more reasonably higher with the current max payload size.

1 Like

Just ran into this issue myself.

Using StudioService:PromptImportLocalAsset() and GetFileContentsBinary() i wanted to put the contents into a script for easy viewing but with larger files I’m unable to.


So far the only thing that can overcome this limitation is making a bot to upload the script and then inserting it from insertservice, because the deserializer doesn’t have this check. Another thing to note is sadly I don’t think roblox paid much attention to this problem and I don’t think they will have any intentions adjusting it anytime soon unless they need to.

1 Like