How do I make a script that kicks everyone except ____

I want to make a script that kicks everyone except for certain users

My issue is that what I have tried errors out.

Here is what I have tried:

game.Players.PlayerAdded:Connect(function(plr)
if not plr.Name == "Name", "Name", "Name", then
plr:Kick("Kicked")
end
end)

If you know anything please help soon! :+1:

Try this:

local playersToNotKick = {
    "Name",
    "Name",
    "Name"
}

game.Players.PlayerAdded:Connect(function(plr)
    if not table.find(playersToNotKick, plr.Name) then
        plr:Kick("Kicked")
    end
end)

This should only kick players whos USERNAME, not displayName are not in the playersToNotKick array/table

1 Like