Loadstring Execution Crashing

A bit of background before I explain my problem

I wanted to test my coding skills, so I asked my friend to obfuscate a require

The way that he obfuscated was bad to say the least, but his method made it so that studio lags horribly when it’s open

In order for me to serialize the code, I change requires to print and then see what it’s requiring

The problem comes with applying these changes

Since the whole script is above 200K characters, I can’t use .Source

Instead, I’m using a custom load string module that I found which has worked well for me in the past, but when I try to execute the edited code, studio crashes, but for some reason when I run it manually in the command line, it works fine

Is there any way that I can fix this issue, or am I just forever going to experience this? Any help is appreciated, thanks in advance

Edit: Added Code

local ls = require(game.ServerScriptService.Loadstring)

function startsWith(String,Start)
	return string.sub(String,1,string.len(Start))==Start
end

function execute(code)
	return ls(code)()
end

function checkSource(assetId)
	local source = game.ReplicatedStorage[assetId].MainModule.Source
	if((startsWith(source, "return require("))) then
		source = source:gsub("return require", "return")
	elseif(startsWith(source, "require(")) then
		source = source:gsub("require", "return")
	else
		print("New asset type? Stopping program, this could be useful")
		return
	end
	local newAssetId = loadstring(source)()
	game.ReplicatedStorage:ClearAllChildren()
	print(newAssetId)
	downloadAsset(newAssetId)
end

function downloadAsset(assetId)
	print("Downloading asset: " .. tostring(assetId))
	local folder = Instance.new("Folder", game.ReplicatedStorage)
	folder.Name = tostring(assetId)
	local objects = game:GetObjects("rbxassetid://" .. assetId)
	for index,object in pairs(objects) do
		object.Parent = folder
	end
	if not (#objects == 1) then
		print("Size not equal 1! There may be something interesting in here, so the program will stop")
	else
		checkSource(assetId)
	end
end

_G.downloadAsset = downloadAsset

-- This gets ran in the command bar, so permissions are satisfied

I use the LoadString module found in Adonis Admin, and I just tested using the regular loadstring() method, and it still crashes

1 Like

Trying to better understand your question. Are you trying to compile (run) obfuscated code through a script?

I’m running code through the command bar to automatically try to get the id that he tries to obfuscate, but it just crashes

I would provide my code, but I can’t atm due to me not being home atm

Without any sort of understanding on what the custom loadstring you are using is, it would be incredibly hard to know if your issue can be solved.

Edited post to include main code and the loadstring algorithm that I’m using, hope that helps a bit