Blacklisting tables and models: does it work?

--setting up overlap params
local olParams = OverlapParams.new()
	local stuff = game.Workspace:GetDescendants()
	local plrs = {}
	for i, v in ipairs(stuff) do
		if v.Name == "Humanoid" then
			table.insert(plrs, 1, v.Parent)
		end
	end
	olParams.FilterDescendantsInstances = {game.Workspace.Baseplate, plrs}
	olParams.FilterType = Enum.RaycastFilterType.Blacklist

essentially this a search for anything with a humanoid, and it is being added to a table, which is then blacklisted. Of course, “anything with a humanoid” means player models. So, this leads me to my question: Can I blacklist a table, and can I blacklist entire models? (Will everything inside the table be blacklisted/every part inside the model be blacklisted?)

1 Like

Ouch, it’s not a good idea to iterate through each and every single object that is in workspace. You’ll either end up heavily loading the server and that will result in an enormous ping or dropping players’ FPS to unplayable levels in case this thing is inside a LocalScript.

EDIT: The severity of this effect, of course, depends on how often you’re going to call that function, but try to avoid it anyway

1 Like

Here’s an example of how you can blacklist all players in the game:

-- Some code above
local blacklisted = { workspace.Baseplate }
for _, plr in ipairs(game:GetService("Players"):GetPlayers()) do
    if plr.Character then
        table.insert(blacklisted, plr.Character)
    end
end
olParams.FilterDescendantsInstances = blacklisted
-- Some code below

And if you have NPC humanoids in your game you wanna blacklist you’ll be safe by managing them inside a Folder in workspace so you won’t have to, again, iterate through each object in workspace. Storing different types of things in folders is a good practice anyway.

I’m getting sidetracked. Yes, you can blacklist entire models. Not sure about tables, though, but there’s nothing stopping you from adding the baseplate to your original blacklist table like I did above.

1 Like

will this work inside a server script? i assume so, but anytime i see game.Players i get a little nervous i guess lol

also, does this mean that blacklisting models/tables is possible?

1 Like

I’ve done an edit of my previous message, you should check it out

1 Like

thanks, thats helpful
also, i see people do for _, v in ipairs and stuff
i understand that, but whats the meaning of the underscore? is that just a replacement for “i” or does it mean something totally different?

1 Like

It’s just a replacement for i.

_ basically means you won’t be using the variable. From my experience, it doesn’t contribute to anything besides making your code a bit cleaner and review-friendly by you explicitly stating that you won’t be using the index variable in your calculations.

I like my code tidy and clean and I come from programming languages where everything you do is explicit by design so I’ll take any chance to make the code more readable and I advise you to follow the same pattern as well. Helps a lot when you develop something as a team.