Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I clear Spread scripts using a script?

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

✓ Accepted answer

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.

6 comments

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.

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

0

No, do not promote deprecated code. :remove() is deprecated.

0

Well, to be fair I used :Destroy() in my code, I just said :remove() is another method that sets the parent to nil.

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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.