It isn't working, and I don't understand what the Output means. Here is the script;
function Encryptor(Encrypt) local String = "" for i = 1,Encrypt:len() do String = String..string.char(92)..Encrypt:sub(i,i):byte() end end wait(5) local cl = script.ScriptBase:Clone() cl.Code.Value = Encryptor([[print("XD")]]) cl.Parent = game.ServerScriptService cl.Disabled = false
The Output said; 19:07:29.174 - String expected
19:07:29.175 - Script 'ServerScriptService.Script', Line 12
19:07:29.176 - Stack End
You're missing one line on the function, the famous return
function Encryptor(Encrypt) local String = "" for i = 1,Encrypt:len() do String = String..string.char(92)..Encrypt:sub(i,i):byte() end return String --Or any value you're attempting to return. end wait(5) local cl = script.ScriptBase:Clone() cl.Code.Value = Encryptor([[print("XD")]]) cl.Parent = game.ServerScriptService cl.Disabled = false
It should work.
Your function lacks a return
, so it evaluates to nil
only.
This return must happen after compiling your string.
May I also recommend clearer variable names? Ideally scripts would read fairly naturally outloud. Names like encrypt
as the parameter aren't really clear; it should be somethign more like text
; we know it is to be encrypted because the function is called Encryptor
(although since it is doing something to something, we should probably use the verb, Encrypt
)
Also, tabbing is important to code readability!
function Encrypt(Text) local EncryptedText = "" for i = 1, #Text do EncryptedText = EncryptedText .. string.char(92) .. Text:sub(i,i):byte() end return EncryptedText end
Remember that any system that just transforms the text like this doesn't actually protect your code if someone gets their hands on all of this: they can just say
loadstring = print
and get everything back.