~Error Bandit (Boss) is not a valid member of Players in Local "char =..."
Within the Bandits folder, there are several Bandits with the same name "Bandit", only 1 that is named "Bandit (Boss)"
I want to damage everyone not in the "ninfect" table.
I started using tables now.
x.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") == nil then
else
if Player.Name ~= part.Parent.Name then
local infect = {}
local ninfect = {}
table.insert(infect, part.Parent.Name)
for i, v in ipairs(infect) do
if part.Parent.Name ~= table.concat(ninfect, "") then
local char = game.Players[v].Character.Humanoid or game.Workspace.Map.Npcs.Bandits[v].Humanoid
char.Health = char.Health - 90
wait(.5)
table.insert(ninfect, part.Parent.Name)
end
end
end
end
end)

4 comments
you're assuming that [v] is already a player model. use findfirstchild to check if the model name is actually a player before experimenting with it
Oh, I forgot that. wait
Line 11: attempt to index a nil value
With FindFirstChild(v)