Help developers!
I am Dan_foodz, I have been making things on Roblox for a year or two.
I will be telling you how to make a basic banning system.
Basic Script useing Player Names:
First think we do is make a server script, name it what you want.
Next thing we do is make a list in the script of banned players:
Line 1: local BannedPlayers = {} -- List of banned players
Next we need to put players into the table:
Line 1: local BannedPlayers = {'PlayerNameHere', 'MorePlayers', 'JustMorePlayers'}
(List can go forever)Next we need to know when the player joins so we use
Players.PlayerAdded
:
Line 1: game.Players.PlayerAdded:Connect(function(Player)
Line 2: -- Blank
Line 3: end)
Next we need to check the banned players and see if one of them is the player that joined using a for loop inside of
Players.Added
:
Line 2: for TimesLooped, BannedPlayerName in pairs(BannedPlayers) do
Line 3: if BannedPlayerName == Player.Name then
Line 4: -- Blank
Line 5: end
Line 6: end
Now in the if statement, we now know the player is on the
BanedPlayers
List. So we will kick the player.
Line 4: Player:kick('You are banned from this game.')
(You can make your own kick message by replacing the text between the two ')And that’s is, if your BannedPlayer from your
BanedPlayers
List joins, it will say:
Full Script:
local BannedPlayers = {'PlayerNameHere', 'MorePlayers', 'JustMorePlayers'}
game.Players.PlayerAdded:Connect(function(Player)
for TimesLooped, BannedPlayerName in pairs(BannedPlayers) do
if BannedPlayerName == Player.Name then
Player:kick('You are banned from this game.')
end
end
end)
Basic Script useing Player UserIds:
First think we do is make a server script, name it what you want.
Next thing we do is make a list in the script of banned players:
Line 1: local BannedPlayers = {} -- List of banned players
Next we need to put players into the table:
Line 1: local BannedPlayers = {12345, 54321, 1232123}
(List can go forever)Next we need to know when the player joins so we use
Players.PlayerAdded
:
Line 1: game.Players.PlayerAdded:Connect(function(Player)
Line 2: -- Blank
Line 3: end)
Next we need to check the banned players and see if one of them is the player that joined using a for loop inside of
Players.Added
:
Line 2: for TimesLooped, BannedPlayerUserId in pairs(BannedPlayers) do
Line 3: if BannedPlayerUserId == Player.UserId then
Line 4: -- Blank
Line 5: end
Line 6: end
Now in the if statement, we now know the player is on the
BanedPlayers
List. So we will kick the player.
Line 4: Player:kick('You are banned from this game.')
(You can make your own kick message by replacing the text between the two ')And that’s is, if your BannedPlayer from your
BanedPlayers
List joins, it will say:
Full Script:
local BannedPlayers = {12345, 54321, 1232123}
game.Players.PlayerAdded:Connect(function(Player)
for TimesLooped, BannedPlayerUserId in pairs(BannedPlayers) do
if BannedPlayerUserId == Player.UserId then
Player:kick('You are banned from this game.')
end
end
end)
Thats all it takes to make a banning system. There is many upgrades you can do to this script, but I will let you do that