I have tried making a BindableEvent so a script finds the trigger and create a module so it the script changes the source of the module but failed so i tried the method
Here’s the script
--Lua app
local data = {}--Module script
function runScript(typenew,source)--Run Lua app
if typenew == "Local" then--If player asks for local script
local newScript = Instance.new("LocalScript",script)
newScript.Source = source--Changes the scripts source
end
if typenew == "Server" then--If player asks for ServerScript
local newScript = Instance.new("Script",script)
newScript.Source = source--Changes the scripts source
end
end
function data.new(typenew ,source)--typenew : what kind of script the player wants ,source : script source
runScript(typenew,source)
end
return data
And also this script only works on plugins or command bar that’s all!
You shouldn’t need environments for executing code. If you want to catch errors, you could use pcall.
local myString = [[
local function errorThread(...)
error(...)
end
errorThread('cool error message')]]
local func = loadstring(myString)
local success, errorMessage = pcall(func)
print(success, errorMessage)
Also just want to add that loadstring returns a function value which can be called as normal, not a thread or anything.