Help for a ban script

OK then the code should work I think.

Just want to point out that this condition is never going to be check as you lower the string so there will be no upper case letter.

With this script you will kick every player in the game, that’s why you get kicked. Turn that into

local targetPlayerUserId = game.Players:GetUserIdFromNameAsync("PlayerYouWantToBanNameGoesHere")

if targetPlayerUserId then
    for i, player in pairs(game.Players:GetPlayers()) do
        if player.UserId == targetPlayerUserId then
            player:Kick()
            break --break out of the loop as the player has been found
        end
    end

    --Add the player's id to a datastore so you can save the ban, doing this here is helpful because it will ban the player regardless of them being in the server meaning you can ban them even if they are offline
end
1 Like

yeah but there was some scripting mistakes so i fixed them then it worked otherwise it gave me errors

What mistakes? I don’t see any going over it.

You have to use the kicked player’s name as a check for the kick. Right Now the only thing your script does is that it checks if you said args[1] aka ;ban and then kicks everyone. You want to check if args[2] aka the player name is valid (is in the server) then kick that player. You may also record that player’s userID in a datastore to kick them if they rejoin.

This is the solution. Right here.

Yeah or above (WinterLife)‘s
[Char Limit]

Please set

or

as the solution.

1 Like