0

# How to check if something is not in a table?

See, what I'm trying to do is have a block be swung like a sword, and check if it's already hit that person to prevent from dealing mass amounts of damage.

Here is the basic script, without dealing any damage.

sword = script.Parent

hitplayers = {}

mainpart.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and (hit.Parent.Name[hitplayers]) == nil then
table.insert(hitplayers, hit.parent.Name)
end
end)


Any ideas?

1

You have to loop through the table.

function InTable(Tab,Val)
for _,n in pairs(Tab) do
if n == Val then
return true
end
end
end

if not InTable({1,2,3,4},77) then
print("HI")
end

0
I think that works, thanks Aaronoles 55 — 7y