[SOLVED] String is "too long" in loadstring?
Asked by
5 years ago Edited 5 years ago
Hi, I have been working on a code obfuscation script, and the part where the code should go has a placeholder in it. When the plugin starts, I use gsub to replace the placeholder with the script and then run loadstring
on the script. Only problem is, Despite the string only being 10895 characters long, it still gives me the string is too long error.
Also note: the script itself works without the loadstring. Only whilst using loadstring on it it decides to be too long
Plugin Script
01 | if not plugin then return end |
03 | local random = plugin:GetSetting( "RandomNum" ) |
06 | plugin:SetSetting( "RandomNum" ,math.random()) |
09 | local button = plugin:CreateToolbar( "VM_Obfuscation" ):CreateButton( "Obfuscate Selection" , "Obfuscates Selected Scripts" , "" ) |
11 | button.Click:Connect( function () |
12 | local rrandom = Instance.new( "StringValue" ) |
13 | rrandom.Value = random |
14 | rrandom.Parent = workspace.CurrentCamera |
16 | button:SetActive( false ) |
18 | local s,m = pcall ( function () |
19 | for i,v in pairs (game.Selection:Get()) do |
20 | if v:IsA( "BaseScript" ) then |
21 | print ( "\nObfuscating " ..v.Name.. "\n\n" ) |
22 | local base = script.BASESCRIPT:Clone() |
23 | base.Source = base.Source:gsub( "lol data goes here i guess" , v.Source) |
24 | print (base.Source:len().. "\n\n" ) |
25 | loadstring (base.Source)() |
28 | repeat wait() until workspace:FindFirstChild( "EncryptedScript" ..random) |
30 | v.Source = workspace [ "EncryptedScript" ..random ] .Value |
31 | workspace [ "EncryptedScript" ..random ] :Destroy() |
32 | print ( "\nObfuscated " ..v.Name.. "\n" ) |
37 | warn( "Couldn't obfuscate script! Send error message to developer of plugin: " ..m) |
Obfuscator's Code
https://pastebin.com/raw/xNvVpiM9 (It was too long for the site)