How can a touched:connect(Hit) function ignore players or certain parts?

I think you can make it false by saying
"**
local ignoretable = {“Humanoid”}

Part.Touched:connect(function(hit)
if hit.ignoretable then
Part = false
else
---- code
end
end) "

I just made a quick thing if you still needed which I’m guessing you don’t but eh, either way here you go:

repeat wait() until game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart")

local ignoreList = {}
local a = false

for i, v in pairs(game.Players.LocalPlayer.Character:GetChildren()) do
	
	if table.find(ignoreList, v.Name) then
		
	else
		if v:IsA("BasePart") or v:IsA("Accessory") then
			table.insert(ignoreList, v.name)
		end
	end

	print(ignoreList)
	
	if not v:IsA("BasePart") or v:IsA("Accessory") then return end
	
	v.Touched:Connect(function(...)
		local args = {...}
		local part = tostring(args[1]) 
		
		if part == table.find(ignoreList, part) then return end
	
		print(args)
	end)
end
2 Likes