How do I extract instances with a specified name out of a table

Hello Fellow Game Developers, I have come here today because I would like to pull an Instance / Multiple instances depending on how many there are out of a table depending if they have a specified name, this is for a hitbox system so I’m using the “HumanoidRootPart” as my Specified Name.

While I have been looking online, I have not found a direct answer assuming It might not exist or it’s something very simple that I just don’t know. So I would like to know if I can possibly do this sort of thing with tables?

1 Like

Some thing like this may be what you are looking for

local SomeTable = {}

for i, v in pairs(SomeTable) do
	if v.Name == "HumanoidRootPart" then
		-- Do what ever
	end
end

This is what I tried to do, and I tried to remove the elements that weren’t as in from the PartsTouching table. (Using ~=) and It just decided to not remove it?? I put a print inside and it printed that it was being deleted, but they were still there when I printed the table.

1 Like

image

1 Like

Try this

table.remove(PartsTouching, table.find(PartsTouching, v))

Even tried putting a wait before it printed to make sure it wasn’t a execution timing issue. Still printed the same thing

1 Like

Very surprised as the only thing that gets removed is one part.

1 Like