I tried making a damage blacklist with tables, but I keep on getting this error

  1. What do you want to achieve? Keep it simple and clear!
    I’d like for there to be a 5 second cooldown in between dealing damage to the same player.
  2. What is the issue? Include screenshots / videos if possible!
    image
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    The script below is the only solution I’ve tried.

local blacklist = {}

script.Parent.Touched:Connect(function(toucher)
	local numberPosition = 0
	local actualNumberPosition = tonumber(numberPosition)
	if toucher.Parent.Name ~= script.Parent.Parent.Name and not table.find(blacklist, toucher.Parent.Name) and toucher.Parent:FindFirstChild("Humanoid") then
		numberPosition = numberPosition + 1
		actualNumberPosition = tonumber(numberPosition)
		toucher.Parent.Humanoid.Health = toucher.Parent.Humanoid.Health - 10
		table.insert(blacklist, toucher.Parent.Name, actualNumberPosition)
		wait(5)
		table.remove(blacklist, actualNumberPosition)
	end
end)

I’m new to tables, so I might be making a stupid mistake.

The second argument of table.insert(t, i, v) is a number, not a string. Just do table.insert(blacklist, toucher.Parent.Name) if you are trying to insert the name.

1 Like

Thank you for your help! Everything is working now.