Help removing multiple lines in bunch of different scripts

So I was doing some stuff trying to fix something (already fixed)
and I tried fixing the collision on the mobs with this script:

while wait() do
	script.Parent.CanCollide = false
end

The problem here is that i have over 450 scripts in game.ReplicatedStorage.Entitys. So I want to remove every script that has that source in game.ReplicatedStorage.Entitys.

I’ve tried searching on forum for this but every post i found was about remove one line of code or replacing one word, and even if I found a post to remove multiple lines it didnt work or was too complex to run.
Please help because it’s causing the npcs to sometimes fall on spawn.

Ctrl + Shift + F

In box 1 type:
while wait() do script.Parent.CanCollide = false end

In box 2 type nothing

Click “Replace All”

This will delete the loop from every script. I think this is what you were trying to request

If you want to delete the actual script, then something like this:

local count = 0
for _, script: Script in ipairs(game.ReplicatedStorage.Entitys:GetChildren()) do
    if string.find(script.Source, [[while wait() do
	script.Parent.CanCollide = false
end]]) then 
        script:Destroy()  
        count += 1
    end
end
warn(`Removed {count} scripts`)

run in console may work

Im on macos but I think your talking about this?


And as you can see it does this. Also I tried this before.

just search “script.Parent.CanCollide = false”

 17:57:29.551  Source is not a valid member of Model "ReplicatedStorage.Entitys.Model"  -  Edit
  17:57:29.551  Stack Begin  -  Studio
  17:57:29.551  Script 'local count = 0
for _, script: Script in ipairs(game.ReplicatedStorage.Entitys:GetChildren()) do
    if string.find(script.Source, [[while wait() do
	script.Parent.CanCollide = false
end]]) then 
        script:Destroy()  
        count += 1
    end
end
w', Line 3  -  Studio
  17:57:29.551  Stack End  -  Studio

You would need to check what instance / object is

knew i forgot something. One moment:

local count = 0
for _, script: Script in ipairs(game.ReplicatedStorage.Entitys:GetChildren()) do
    if not script:IsA("Script") then continue end
    if string.find(script.Source, [[while wait() do
	script.Parent.CanCollide = false
end]]) then 
        script:Destroy()  
        count += 1
    end
end
warn(`Removed {count} scripts`)
1 Like

Yes, but this will only remove script.Parent.CanCollide = false, and it would output like a million errors.

bro how many of those same 3 lines of code do you have in your game :sob:

I was trying to fix something lol

Btw it just says Removed 0 scripts
Btw Im running this in the command bar.

my point is to search for that one single line then check the script and delete there manually.

This will take me like 5 hours :sob:
Screenshot 2024-05-18 at 6.04.37 PM

Also the whole point of this post is to do this automatically.

OK i made it changed again:

local count = 0
for _, script: Script in ipairs(game.ReplicatedStorage.Entitys:GetChildren()) do
	if not script:IsA("Script") then continue end
	source = script.Source
	source, _ = string.gsub(source, "\n", "")
	source, _ = string.gsub(source, "\t", "")
	source, _ = string.gsub(source, " ", "")
	if string.find(source, "whilewait()doscript.Parent.CanCollide=falseend", 1, true) then 
		script:Destroy()  
		count += 1
	end
end
warn(`Removed {count} scripts`)

Note that it does remove the scripts entirely, as that is what it seemed like you were asking initially.

It worked but I modified it:
local count = 0
for _, script: Script in ipairs(game.ReplicatedStorage.Entitys:GetDescendants()) do
if not script:IsA(“Script”) then continue end
source = script.Source
source, _ = string.gsub(source, “\n”, “”)
source, _ = string.gsub(source, “\t”, “”)
source, _ = string.gsub(source, " ", “”)
if string.find(source, “whilewait()doscript.Parent.CanCollide=falseend”, 1, true) then
script:Destroy()
count += 1
end
end
warn(Removed {count} scripts)

Thank you so much for saving me like 891241247 hours :pray:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.