Roblox Lua Wiki
Advertisement

This article focuses on the string.dump() function. This function is commonly overlooked for its complexity.

Note: string.dump function are not supported of roblox because of exploits involved around roblox!

Usage[]

What the dump function does is takes a function as an argument (not a string) and "dumps" it into binary format. Now I know you probably don't understand this because it is not a complete binary formation. It is just partial. Once you have dumped the function you may run it in the loadstring function and it will run like it did before you dumped it into binary format. So lets try that:

local func = function() print("Hello") end
local dumped = string.dump(func)
loadstring(dumped)()
>Hello

Now that you dumped the function and ran it with loadstring it has printed "Hello" in the output like it is supposed to. But lets say you don't want to run the function, but just print it in the output? Well lets try that:

local func = function() print("Hello") end
local dumped = string.dump(func)
print(dumped)
>LuaQ

What in the world does that mean? It is the dumped function printed of course! But when you try to load THAT in loadstring it will not work. The reason why is because there are some thing in the dumped function that the print function cannot print to the output. For this reason you have to make your own script that will get these. The easiest way to do this is make a script that uses string.byte on all the binary letters and number before it is printed. Here is an example:

local func = function() print("Hello") end
local dumped = string.dump(func)
local newstring = ""
for i = 1, string.len(dumped) do
newstring = newstring .. "\\" .. string.byte(string.sub(dumped,i,i))
end
print(newstring)
>\27\76\117\97\81\0\1\4\4\4\8\0\18\0\0\0\61\87\111\114\107\115\112\97\99\101\46\83\99\114\105\112\116\0\1\0\0\0\1\0\0\0\0\0\0\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\128\0\2\0\0\0\4\6\0\0\0\112\114\105\110\116\0\4\6\0\0\0\72\101\108\108\111\0\0\0\0\0\4\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0

Wow! What are all those numbers and symbols. Well all those numbers are the letters and numbers that the print function cannot put into the output. So we changed them to number form using string.byte. Those dashes turns those numbers into the correct letters and numbers when you run them in a script. Now we need to call those numbers in loadstring like this:

loadstring("\27\76\117\97\81\0\1\4\4\4\8\0\18\0\0\0\61\87\111\114\107\115\112\97\99\101\46\83\99\114\105\112\116\0\1\0\0\0\1\0\0\0\0\0\0\2\4\0\0\0\5\0\0\0\65\64\0\0\28\64\0\1\30\0\128\0\2\0\0\0\4\6\0\0\0\112\114\105\110\116\0\4\6\0\0\0\72\101\108\108\111\0\0\0\0\0\4\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\1\0\0\0\0\0\0\0\0\0\0\0")()
>Hello

There! Now you have successfully dumped an entire function into binary format. This is not decodable so you must backup your function you dump before dumping it into binary.

[]

Function Dump

Advertisement