How to create an instance name filter?

As of right now I have been trying to create a simple anti-exploit script that’s supposed to prevent toolbox-importing exploits; problem is I want to be able to simplify the if statement where it checks on whether or not the workspace child instance has the correct name or whether or not its a player but I dont know how to go about that.


any help?

Note: If anyone could also help me identify if the child is also a player or not that would be appreciated. I’ve been scratching my head on this as well.

Players:GetPlayerFromCharacter (roblox.com)

local _list = {"thumbnail"}
local ListType = "blacklist"
local PlayerCharactersOnly = true
workspace.ChildAdded:Connect(function(child)
	if (game.Players:GetPlayerFromCharacter(child) == nil and PlayerCharactersOnly) or (table.find(_list, child.Name:lower()) ~= nil and ListType == "blacklist") or (table.find(_list, child.Name:lower()) == nil and ListType ~= "blacklist") then
		local success, err
		repeat
			wait()
			success, err = pcall(function()
				child:Destroy()
			end)
		until
			success
		warn("Removed "..child.Name.." from workspace")
	end
end)
Players = game:GetService("Players")

local passablenames = {} -- Insert whitelisted names here.

Is_Name_OK = function(object)
	local passable = false
	
	for _, entry in pairs(passablenames) do
		if object.Name == entry then
			passable = true
			break
		end
	end
	
	return passable
end

Players:GetPlayerFromCharacter is a function that returns the Player connected to a passed object, if the object is the Character of a Player.

CheckPlayer = function(object)
	if Players:GetPlayerFromCharacter(object) then
		return true
	else
		return false
	end
end