Is Loadstring Safe? Roblox Loadstring Explained
Loadstring itself is not malware. It is a Lua function that compiles a string into runnable code at runtime. It is risky because whoever controls that string controls your game, which is why Roblox disables it by default and never allows it on the client. Most games should leave it off; protected code can run without it.
What does loadstring actually do?
In standard Lua, loadstring (load in newer versions) takes source code as a string, compiles it, and hands back a function you can call. It is the language's built-in way to turn data into code.
local f = loadstring("return 2 + 2")
print(f()) -- 4
-- The string can come from anywhere: a variable, a DataStore,
-- an HTTP response. Whatever it says, it runs with the same
-- privileges as the script that called loadstring.That last property is the entire safety question. There is no sandbox between "string someone gave you" and "code executing in your game." If an attacker can influence the string, they are no longer exploiting your game logic, they are writing it.
Why is loadstring disabled by default on Roblox?
Roblox ships with loadstring turned off, and the on switch only exists for the server: the LoadStringEnabled property on ServerScriptService. There is no supported way to enable it inside client scripts. The reasoning is straightforward: loadstring converts any string-injection bug into full remote code execution.
- Backdoors love it. The classic free-model backdoor is a hidden script that listens on a remote and passes whatever it receives to loadstring. With loadstring off, that payload path is dead even if the backdoor gets into your place.
- It turns small bugs into total compromise. A RemoteEvent that forwards a player-supplied string into loadstring hands every exploiter a server console.
- It defeats code review. You can read every script in your place and still not know what the game will run, because the real code arrives later as data.
A useful habit when auditing free models and plugins: search for loadstring, getfenv, and require calls with an asset id. Finding one is not automatically malicious, but it means the code you can read is not the code that will run.
Is it ever safe to enable LoadStringEnabled?
It can be defensible in narrow cases: an admin-command system that only trusted developers can reach, a sandboxed scripting playground where running user code is the product, or in-house tooling. Safe use requires that untrusted players can never influence the string, directly or through any remote, DataStore, or HTTP path.
The honest cost-benefit for a typical game: you gain a convenience you will rarely use, and you widen the blast radius of every other vulnerability you ever ship. Most professional Roblox games leave it off permanently and are no worse for it. If you only want loadstring to run obfuscated code, keep reading, because you do not need it for that.
Why do so many obfuscators require loadstring?
It is the easy way out for the obfuscator author. Encode the script into a string, ship one line that decodes it and hands it to loadstring, done. That design fails twice on Roblox. On the client it simply cannot run, because client loadstring does not exist, so LocalScripts are unprotectable with such a tool. On the server it works only if you flip LoadStringEnabled, which means your protection now depends on enabling the exact primitive that backdoors rely on.
You will also see loadstring(game:HttpGet(...)) patterns around the exploit scene. That is a distribution mechanism for executor scripts, not something a game developer can or should use for protecting their own work: it runs in executors, not in real games, and it means running whatever a remote URL serves today.
How do you run protected code without loadstring?
The alternative is to stop treating code-as-a-string as the delivery format. A bytecode VM obfuscator compiles your script to a custom instruction set, then emits a plain Luau program containing a small interpreter and the encoded instructions. The output is ordinary runnable Luau. Nothing is compiled at runtime, so no loadstring, no engine flags, and it works in LocalScripts, ModuleScripts, and server Scripts as-is.
This is how Joker's Lua protection works, which is why LoadStringEnabled stays off. The same output runs on FiveM and Garry's Mod, which have their own execution rules and where a loadstring-shaped design causes different but equally real problems. Details are on the Roblox obfuscator page at /roblox-obfuscator, and the free tier's 300 credits are enough to verify the no-loadstring claim on your own script instead of taking our word for it.
The short version
- Loadstring is a legitimate language feature whose risk is entirely about who controls the string.
- Roblox disables it everywhere by default and offers no client-side enable at all.
- Turning on LoadStringEnabled to satisfy an obfuscator inverts your security posture: you weaken the game to protect the code.
- If a protection tool requires loadstring, it cannot protect LocalScripts on Roblox. Treat that as a disqualifier and pick a tool that emits plain runnable Luau instead.