What Is loadstring?
Understanding loadstring
In Luau, the loadstring function is used to compile a string of Lua source code into a callable function. This allows developers to execute dynamic code at runtime, which can be powerful but also poses certain risks.
However, it's important to note that loadstring is disabled on the Roblox server by default due to security concerns. This means that while you can use it in local scripts or in certain environments like executors, it is not available in standard Roblox game scripts running on the server.
How loadstring Works
The basic syntax of loadstring is as follows:
local func = loadstring(