:GetDescendants and "BasePart" help

I’m attempting to use :GetDescendants to cycle through my character and find specific instances and delete them, where can I find the list or the names of all names i can use for :IsA, things like “:IsA(“BasePart”)”, and Particle Emitter, ect. Where can I find all the other terms? And could I use “:GetDescendants” and then using i,v in pairs, cycle through descendants and if they have a specific name or would there be a better way to do that?

Any and all help is very very appreciated. I’m a solo dev doing anything from animations, models and vfx to scripting, sound design and custom textures.

These names that your referencing is the Instance’s classname. You can go here and everything under this category is a vaild class name that you can put into the quotes to filter through.

I am a tad confused what you mean here but yes this is how you could use :GetDescendants. Here is an Example:


local folder = Workspace.ExampleFolder

--Whats in the folder: 

--Part 
  --> Script 

-- Local script

--Part 
   --> Model 
      --> Audio 
         --> Module Script

for Index, Object in folder:GetDescendants() do 
    if Object:IsA("BaseScript") then 
        print("This is a Base Script!") 
        print(Object.ClassName)
    end
end


--This is what it prints: 

 --This is a Base Script!
 --Script 
 --This is a Base Script!
 -- LocalScript
 --This is a Base Script!
 --ModuleScript

1 Like

Thank you, the class names is just what I needed, and what I meant by the names, I meant like, if I could get the descendants of a model or istance and do something like:

for i,v in pairs("Instance") do
      if v.name == "Certain Name" then
            v:Destroy()

Something like that, would that be super bad due to the number of things it’d have to sift through?

Usually its not that bad and is the method to do that type of filtering. You may come across issues when doing that filtering above 5000+ objects and sometimes a yield is needed. If you notice any lag spikes coming from that code, adding yields can help it. But with that being said, no Its not super bad, and its the way to do it.

going to try this right now. Thank you once again

1 Like

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