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.
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`)
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
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`)
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)