I want to make something for my model. I want to add an "anti-virus" thing so if I tried a script, which is a virus, it'll scan the code and tell if it's safe or not before running it. But my problem was the scanning itself. Is there a way to make scripts read scripts? If yes, how does one achieve it? Thanks.
You can't edit a script using another script. However, you can use it's functions if you add _G.
For example:
_G.name = function() print("Soup time") end
Using another script, you can call the function by doing:
_G.name()
Hope this helps!
Sorry mate, but you can't edit other scripts sadly.
What you Can do however is destroy scripts that are inserted after the game runs. It's not a full-proof way to do it but it's about as close as you can get.
local Model = script.Parent local Whitelist = {} --Configs-- local AllowBase = false --Toggle true to allow scripts that are present when game starts --End configs-- for i, v in pairs(Model:GetDescendants()) do if v:IsA("BaseScript") and AllowBase == false then v.Disabled = true v:Destroy() end end Model.DescendantAdded:connect(function(instance) if instance:IsA("BaseScript") then v.Disabled = true v:Destroy() end end)
Generally speaking you shouldn't be inserting scripts into the workspace after the game is running anyway. More secure that way.
There is a more complicated way to do it, but by that point it's probably just easier to go with the "MainScript" in ServerScriptService rather than whitelisting certain scripts.