local waitTime = 0.2 local Debounce = false local Char = {} local function Touched(hit) if not Debounce then if not hit.Parent:FindFirstChild("Humanoid") then return end Debounce = true hit.Parent:SetAttribute("Damage", true) table.insert(Char, hit.Parent) wait(waitTime) Debounce = false end end local function TouchEnded(hit) if not Debounce then if not hit.Parent:FindFirstChild("Humanoid") then return end Debounce = true hit.Parent:SetAttribute("Damage", false) table.remove(Char, table.find(hit.Parent)) wait(waitTime) Debounce = false end end script.Parent.Touched:Connect(Touched) script.Parent.TouchEnded:Connect(TouchEnded) while task.wait(waitTime) do if table.getn(Char) > 0 then for _, Plr in pairs(Char) do if Plr:GetAttribute("Damage") == true then Plr.Humanoid:TakeDamage(10) end end end end
help
table.find
takes at least 2 arguments. First the table, then the value you're looking for. It only returns the first occurrence, so you should make sure there's only one.
On line 10:
if table.find(Char, hit.Parent) == nil then table.insert(Char, hit.Parent) end
(table.find returns nil if the value was not found.)
Line 21:
table.remove(Char, table.find(Char, hit.Parent))