A question about a ban script

So if your an experienced scripter, you would probably know how to make a simple ban script which is something like this:

Server Script

local BanList = {
    82736483983;
    - - some more UserIds here.
}

game.Players.PlayerAdded:Connect(function(plr)
    if BanList[plr.UserId] then
        plr:Kick(“You are banned from this game.”)
    end
end)

Now here’s a question about it. Let’s say you have a game moderator that bans someone in one of your game servers. How can I make it so that that player is banned forever? Do I need to add the UserId into the list manually? Or is there an effective way for me to do this instead of just manually adding UserIds into the table every single time?

If you want to dynamically ban players at runtime you’ll have to use a DataStore.

Also to check if a value is in array you should use:

if table.find(BanList, plr.UserId) then
2 Likes

If possible, may I have an example?

u can add a bool value to a player that is checked and named “isbanned” and you can make a gui that is special for admins that will type a username and when they enter, the bool value is checked off and it also kicks the player after

this is when datastore is useful, it saves the bool’s value then when a player goes in and it’s checked, they get kicked, you have to use like a off-site roblox service for the admins to be able to unban them even if they aren’t in-game or something else

atleast thats how it works

This is a simple ban script that I usually use

print ("JavaKingz's Permanent Ban System || LOL")

local bannedPlayers = {
	"JavaKingz";
	"Roblox";
} 

local banMessage = "You have been permanently banned from the game!!!!!!!!!!!!"

function onEnter(player)
	for i=1, #bannedPlayers do
		if player.Name == bannedPlayers[i] then
			player:Kick(banMessage)
		end
	end
end
 
game.Players.ChildAdded:connect(onEnter)

Well, it doesn’t work.
It only save bans in one game server, not the other.


Instead, Use datastore and save bans.
Tutorial and document: