Why is the blacklist not working?

So the HydraulicPress is supposed to damage the part only once, but it damages parts multiple times even if the part is in the blacklist.

local function destruction(HydraulicPress, number)
	local blacklist = {}
	HydraulicPress.Touched:Connect(function(touchedPart)
		
		if touchedPart:FindFirstChild("HP") and table.find(blacklist, touchedPart) == nil then
			table.insert(blacklist, touchedPart)
			touchedPart.HP.Value -= HPandDMG.DMG[tostring(number)]
		
		
		end
	end)
end

this should work
believe the issue was that the .Touch was getting multiple parts of the player and since you only blacklisted a certain part at a time and not the whole player it kept doing damage for each part

local function destruction(HydraulicPress, number)
	local blacklist = {}
	HydraulicPress.Touched:Connect(function(touchedPart)
		local Character = touchedPart.Parent
		if touchedPart:FindFirstChild("HP") and not table.find(blacklist, Character.Name) then
			table.insert(blacklist, Character.Name)
			touchedPart.HP.Value -= HPandDMG.DMG[tostring(number)]
		end
	end)
end
1 Like

the problem is, that the part i want to damage is an actual part that contains NumberValue in it, not a player. But your script gave me an idea and i think im going to implement a boolvalue which sets itself to true whenever the part is blacklisted.

You could always use CollectionService, So u don’t have to work with a blacklist and just sellect the parts u want. CollectionService | Roblox Creator Documentation

1 Like

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