Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I clear Spread scripts using a script?

Asked by 6 years ago

So, my builder used many free models and they contained the Fire Spread script. And I want to remove them but I am too lazy because there are too many.. I tried this script, but I don't know how I will complete it.

Script:

local descendants = game.Workspace:GetDescendants()

for index, descendant in pairs(descendants) do
 if descendant.Name == "Fire" then

 end        
end

1 answer

Log in to vote
0
Answered by
maxbd 44
6 years ago
Edited 6 years ago

I don't know what a "Fire spread script" is, but I've seen things that sound similar. Try using this script instead, it should work to remove all the spammed objects, but it's untested.

function clean(name, path, otype)
    for i,v in pairs(path:GetChildren()) do
        if v:IsA(otype) == true and v.Name == name then
            if v:GetChildren() ~= nil then
                clean(name, v, otype)
            end
            v:Destroy()
        end
    end
end

Now you just call the function with whatever parameters you want, because I don't know what the fire spread script is.

Side note: If your "developers" use free models, fire them.

EDIT: If you're asking how to complete that script, you can use the :Destroy() method to destroy the objects, or the :remove() method if you want to set their parent to nil.

0
The script didn't work, but I managed to complete my own. Thanks anyways! am gonna give you the script if the same happens to you! PS: Spread fire scripts are scripts that spread fire in your game for the hopes of making it laggier. thefatrat87 18 — 6y
0
local descendants = game.Workspace:GetDescendants() local amount = 0 for index, descendant in pairs(descendants) do if descendant.Name == "Fire" or descendant.Name == "Smoke" then descendant:Destroy() amount = amount + 1 if amount >= 620 then print(amount.." viruses removed, omg") end end end thefatrat87 18 — 6y
0
No, do not promote deprecated code. :remove() is deprecated. User#19524 175 — 6y
0
Well, to be fair I used :Destroy() in my code, I just said :remove() is another method that sets the parent to nil. maxbd 44 — 6y
View all comments (2 more)
0
No, deprecated code is never the way to go. You can simply set it to nil by manually assigning the parent to nil. obj.Parent = nil User#19524 175 — 6y
0
And :Destroy() is different than :remove(), all :remove() does is set the parent to nil whilst :Destroy() does that, disconnects all connections, and LOCKS the parent property, and prepares the object for garbage collection. User#19524 175 — 6y
Ad

Answer this question