How do I define any of part in a group with the same name

How to do something like I want to make it like part touch all parts with the same name that in a group on the workspace. Thank you.

Could you please explain thoroughly? Some people may not be able to understand what you are trying to point out.

Ok I need to try and translate. It’s 3AM and I’m exhausted. Let’s get it.

Okay so you have a bunch of parts that share the same name in a Group.

You want to add a touch listener to every single part named a specific thing?

Let me know if I got this right, if I did I’ll assist you if you’ve not already figured it out.

I need a nap, or something.

Put all of your parts in a folder, then use a loop. Example:

for i, Part in pairs(workspace.PartFolder:GetChildren()) do
	Part.Touched:Connect(function(hit)
		if db == false then
			db = true
			-- code for when any part inside of PartFolder is touched
			wait(.1) -- Adjust this
			db = false
		end
	end)
end
for _ , v in pairs(Workspace:GetDescendants()) do
   for _ , v2 in pairs(Workspace:GetDescendants()) do
      if v.Name == v2.Name and v.Parent.Name == v2.Parent.Name then
         --//Whatever You Want To Do With it
      end
   end
end
1 Like