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

what is the best way to find multiple parts with a certain name?

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

2 comments

1

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.

0

thank you

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.