How do I whitelist a part to Debris?

How do I whitelist a part to Debris?
or to the code in general.

here is my code:

boom.Hit:Connect(function(part: BasePart, _)
			part.Anchored = (part == mine) or false
			
			if hit.Parent:FindFirstChild("Humanoid") then
				hit.Parent.Humanoid.Health = 0
			end;
			Debris:AddItem(part,5)
		end)

to whitelist a part, you should use a table. Put your whitelisted parts in the table, then check if the part is in the table
Like this:

local whitelistedparts = {Part1.Part2,Part3}

boom.Hit:Connect(function(part: BasePart, _)
if not table.Find(whitelistedparts,part) then return end
	part.Anchored = (part == mine) or false
			
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = 0
	end;
	Debris:AddItem(part,5)
end)
1 Like

I want to make sure Debris doesn’t effect the whitelisted parts.

Just put the if not before the Debris

local whitelistedparts = {Part1.Part2,Part3}

boom.Hit:Connect(function(part: BasePart, _)
	part.Anchored = (part == mine) or false
			
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = 0
	end;
if not table.Find(whitelistedparts,part) then return end
	Debris:AddItem(part,5)
end)
1 Like

return end should go after Debris, Thank you anyways!

whitelisting means that the parts in the table are the only ones that are being added to debris
did you mean blacklisting? because it means that it will add anything except the parts from the table to debris

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.