~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)
I assume that "Player" has a value, otherwise you would not be attempting to call a nil value. I'm going to just assume you gave it a value and didn't tell us.
x.Touched:Connect(function(part) if not part.Parent:FindFirstChild("Humanoid") 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 not ninfect[part.Parent.Name] then assert(v:IsA("Player"), "Did not receive a player object") -- Stops script if v is not a player 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)
Not 100% sure what you were trying to do, but either way, I made some minor changes to make it easier to read.
also made a check that v is even a player