INFO | I am trying to, trough a server script, check for wether within a specific game, the loadstring option is turned on, or turned off. Then using the info i would like to print, for example “loadstring turned on” or “loadstring turned off” depending on the result.
ISSUE | I dont know how to achieve this, theres no documentation and i dont think its possible, but if it is please let me know. Thank you!
Sorry lol, my post was a bit confusing. Im trying to check trough a server script, if the loadstring option is enabled in the specific place, or not. If its enabled id like the script to for example print enabled, else print disabled.
ServerScriptService.LoadStringEnabled is toggle-able in studio but cannot be read by scripts except through the command bar and plugins. As @brokenVectors sugggested you can see if it is enabled by testing whether calling the function will throw an error.
If you need to execute code when loadstring is disabled you can use a VM instead.
Edit: Reading the LoadStringEnabled property doesn’t work for plugins or the command bar either.
This one is published as a module script by @Reinitialized, and it returns a function that you can use in pretty much the same way as the old loadstring function.
If you plan on using it I found a small error in the ‘Loadstring’ module, so you’d want to change this section of code:
local waitDeps = {
'Rerubi';
'LuaK';
'LuaP';
'LuaU';
'LuaX';
'LuaY';
'LuaZ';
}
for i,v in pairs(waitDeps) do script:WaitForChild(v) end
to this:
local waitDeps = {
'FiOne';
'LuaK';
'LuaP';
'LuaU';
'LuaX';
'LuaY';
'LuaZ';
}
for i,v in pairs(waitDeps) do script:WaitForChild(v) end
So it doesn’t timeout.
To run it you would do something like this:
local loadstring = require(game.ServerScriptService.Loadstring)
local func = loadstring("print('hello')")
func() -- hello
For documentation, the creator included a ‘Credits’ script inside the module with links to the source code.