I was messing around with plugins and then realized that they inserted multiple requires into scripts, and I was wondering what would be a quick way to remove them from all of these scripts?
print("testing1")
require(3453535454) -->> AFTER RUNNING THE PLUGIN THIS SHOULD BE REMOVED FROM THE CODE
heres the thing; nearly 10000 scripts are infected, and doing this is extremally inefficient, so i was wondering if I could script a plugin to make it go a little faster
many people make this mistake. gsub does not change the value directly, instead it returns the changed string. So what you did is, game.Workspace.Script.Source take the string âcode blah blahâ, then gsub it, then it returns the gsub-ed string, but it did not change the Source yet.
What you should do instead is this Script.Source = Script.Source:gsub("require(3434344343443)", "")
But since you said there are thousands of script affected, this is ineffecient
Edit: just tested this, apparently â(â and â)â are magic characters and is detected by the string patterns. You need to add â%â signs before those characters Script.Source = Script.Source:gsub("require%(3434344343443%)", "")
This is janky because youâre gonna be running it in the command line but you need to escape the parentheses because theyâre special characters or whatever, thisâll work but might freeze studio because youâve 10000 scripts (sorry didnât see your script lielmaster):
for i,v in ipairs(game:GetDescendants()) do
pcall(function()
v.Source = v.Source:gsub('require%(3453535454%)', '')
end)
end
It wonât error, you can run game:GetDescendants, you just canât index any of the instances without an error which is why you need to wrap it in a pcall.
yes, anyways you can use @7z99âs method or this. Any would work
local services = {"Workspace","Players","Lighting","MaterialService","ReplicatedFirst","ReplicatedStorage","ServerScriptService","ServerStorage","StarterGui","StarterPack","StarterPlayer","Teams","SoundService","Chat"}
for _, v in pairs(services) do
for _, script:Instance in pairs(game[v]:GetDescendants()) do
if script:IsA("LuaSourceContainer") then script.Source = script.Source:gsub("require%3434344343443%)", "") end
end
end