what is the best way to find multiple parts with a certain name? for an example I have a random number of bricks in the workspace called Damage and i what a script it find them and run some lines for script in them they could be in models or other parts the only way i can think of is for i,v in pairs () do
✓ ANSWER ACCEPTED
what is the best way to find multiple parts with a certain name?
1 answer
✓ Accepted answer
You can loop through all parts in the workspace using :GetDescendants() and check their name. Here is an example:
for i,v in pairs(game.Workspace:GetDescendants() do
if v:IsA("BasePart") then --check if v is a physical part
if v.Name == "Damage" then --check if v's name is Damage
--v is a part named "Damage"
end
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
If you want to clear through every possible Instance within workspace. use :GetDescendants() in conjunction with a pairs loop, yes. Compare the current attribute Name using a conditional.
thank you