Well, I need help with one thing, I don’t know if it is easy or difficult, but I want to make a script that detects all objects, for example. I want it to detect only the “Lighting”, and to be able to make use of Lighting by activating it, deleting it, moving it, etc. I know how to use the “GetDescendants” but I don’t know how to use it so that it detects all the lighting
2 Likes
If you’re referring to Models
that are called “Lighting”, you can utilize a loop that will check for the Instance’s ClassName (in this case, Model), Name (Lighting), etc., before modifying the Instance.
Example
for _, item in ipairs(workspace:GetDescendants()) do
if item:IsA("Model") and item.Name == "Lighting" then -- Checks if the Item that was found is a Model & if its name is Lighting
-- Continue with code
end
end
Note: Depending on how you’ve organized those models/where they are in the game, you can alter what Instance the :GetDescendants
method is called on or even result to using :GetChildren()
if they’ve been consolidated to a single place. It won’t be as performant when called on the workspace since it’d go through everything in the service.
1 Like