Hello,
How do I make a pbanlist system then when I do pban [player] and an player gets banned with reason [message]?
Hello,
How do I make a pbanlist system then when I do pban [player] and an player gets banned with reason [message]?
You can make a script that kicks a player if a “banned” value in a datastore is set to true. For the reason, you can use an other value.
How do I do it from begin? Local Script? Normal Script?
You would do it via a normal (server-sided) script.
A normal script,
I can’t access my DataStore scripts because of the outage but to kick the player you can do :
if bannedvalue == true then
player:Kick(reasonvalue)
end
Oh what about when I don’t want any groups to access into my game? For example: A group of ID that isn’t allowed.
You would still use a normal (server-sided) script. You would use a function tied to the PlayerAdded event (linked below). Next, you would check if the player is in the group using :IsInGroup (linked below also). Then, if they are in the group, kick them.
PlayerAdded: Players | Documentation - Roblox Creator Hub
IsInGroup: Player | Documentation - Roblox Creator Hub
According to @COUNTYL1MITS , you can use this :
game.Players.PlayerAdded:Connect(function(plr) -- Gets the player
if plr:IsInGroup(<GroupID>) == then -- Checking if the player is in the group (<GroupID>)
plr:Kick("You are inside a Blacklisted group !") -- Kicks the player if he is in the group
end
end)
Though I’d recommend you’d not use any method of group blacklisting.
There could be people who just joined a group who haven’t done anything associated with it, and if they happen to enter your game it’ll just appear like they’re being punished for no reason.
Keep it tied to smaller groups if this is an absolute must to have.
To create an admin command chat script you would have to use the Player.Chatted event to see when a user talks. That event will return the message that was sent.
You should then use string manipulation to separate the command from the target player, along with making sure the user who sent the message is an “admin” who can pban.
After that, you can use DataStoreService to store the information about how the player is banned. Any time a player joins the game, check this data to see if they are permanently banned. If they are, use Player:Kick to remove them from the game.
This is not a request forum for anyone to script things for you, so I will not give you the actual code to a pban script. I hope these resources will prove to be useful to you, and if you are really stuck you could always just use a normal admin script.
There are multiple ways you could do this, it really depends on what you want to do. It’s better to have some type of scripting before asking for ways or advice since the category is for asking advice on already existing code and not asking for a whole system. Since I myself had time I did do a little long of a post giving you code and it seems you are a builder and with very little scripting knowledge.
It is always better to keep your script simple and readable rather than having a bunch of statements that can be effectively reduced with 2-3 lines of code.
For future references, there is a Roblox Developer Hub where you can search up functions and information about scripting to help you out. They have sample scripts on there and it’s great site for looking up things you are not comfortable with to get more insight on how to effectively use things in scripting.
Notes
Resourses:
A good method for banning people is using a table that has names in it that you can loop through it and if their username is in the table or you can use their UserId as an identification, then they would be kicked.
Example:
local Blacklisted = {"NAME",00000} -- Add usernames or UserId's according to the type of argument you use in your
You can also just use the simple method which would require an extra amount of scripting that is not needed and is not really good practice. This method works well if you just want to ban one person but it’s better to use the first method, but it’s your choice.
if Instance.Name == "NameOfBanned" then
end
There are events like :GetRankInGroup() and :IsInGroup() which can be used for another form of a reason to ban a person.
You can have the script set up whatever way you wanted, but there are 2 basic examples. I will show you the ways with the table.
With the table (Using UserId and Usernames)
Example 1:
local Blacklisted = {"Roblox"}
local BannedMessage = "You have been banned" -- Replace with your message
local function CheckBan(Player)
for i , v in pairs(Blacklisted) do
if v == Player.Name then
Player:Kick(BannedMessage)
end
end
end
game.Players.PlayerAdded:Connect(CheckBan)
Example 2:
local Blacklisted = {1829272} -- Replace with other ID's
local BannedMessage = "You have been banned" -- Replace with your message
game.Players.PlayerAdded:Connect(function(Player)
for i , v in pairs(Blacklisted) do
if v == Player.UserId then
Player:Kick(BannedMessage)
end
end
end)
With the table (Using Group Id’s)
local BlacklistedGroups = {3174578} -- Replace with group ID's
local BannedMessage = "You are in a blacklisted group"
game.Players.PlayerAdded:Connect(function(Player)
for i , v in pairs(BlacklistedGroups) do
if Player:IsInGroup(v) then
Player:Kick(BannedMessage)
end
end
end)
Using a different method with ID’s and Usernames (Unrecommended)
Example 1: (Usernames)
local BannedMessage = "You have been banned"
game.Players.PlayerAdded:Connect(functon(Player)
if Player.Name == "Roblox" or "Templates" or "Noob" or "zlib" then
Player:Kick(BannedMessage )
end
end)
Example 2: (UserId’s)
local BannedMessage = "You have been banned"
game.Players.PlayerAdded:Connect(functon(Player)
if Player.UserId== 2394723 or 1 or 86146332 or 32821 then
Player:Kick(BannedMessage )
end
end)
These types of scripts are not allowed in Roblox.
I can share my code for bans (sry that it isnt easiest, but it is extremly easy to add new commands, the command is fired there by remote event and triple sry that var names are in my language so you can easily lost in it)
--vars
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player
local createPartEvent = Instance.new("RemoteEvent", ReplicatedStorage)
local DataStore = game:GetService("DataStoreService"):GetDataStore("pravomoce")
local comand
local povoleni
local povolenin
local slovoZId = {
[0]="new",
[1]="veteran-player",
[2]="trusted-player",
[3]="comunity-mederator",
[4]="moderator",
[5]="top-moderator",
[6]="admin",
[7]="head-admin",
[8]="co-owner",
[9]="owner"
}
local idZSlova = {
["new"]=0,
["veteran-player"]=1,
["trusted-player"]=2,
["comunity-mederator"]=3,
["moderator"]=4,
["top-moderator"]=5,
["admin"]=6,
["head-admin"]=7,
["co-owner"]=8,
["owner"]=9
}
local comands={}
--ban and unban function
function comands.ban (plr)
local rank = DataStore:GetAsync(game.Players:GetUserIdFromNameAsync(plr))
rank=rank or "new"
if (idZSlova[rank]<(povolenin-1))or ((idZSlova[rank]<povolenin)and povolenin==9)then
DataStore:SetAsync(game.Players:GetUserIdFromNameAsync(plr),"ban")
game.Players:FindFirstChild(plr):kick(player.Name.." gived you ban")
end
end
comands.banlevel=6
function comands.unban (plr)
if DataStore:GetAsync(game.Players:GetUserIdFromNameAsync(plr))=="ban" then
DataStore:SetAsync(game.Players:GetUserIdFromNameAsync(plr),"new")
end
end
comands.unbanlevel=6
--cmd choosing system
function Cmd (plr,cmd)
player=plr
povoleni = DataStore:GetAsync(plr.userId)or "new"
povolenin = idZSlova[povoleni]
print(povolenin)
cmd=cmd:gsub("\\\"", "\255")
local tempcomand = cmd:split("\"")
comand={}
for i,v in pairs(tempcomand)do
if v ~= nil and v:len()>0 then
v=v:gsub("\255","\"")
v=v:gsub("\\\\","\\")
if i%2 == 1 then
local tempcomand2 = v:split(" ")
for _,v2 in pairs(tempcomand2) do
if v2 ~= nil and v2:len()>0 then
table.insert(comand,v2)
end
end
else
table.insert(comand,v)
end
end
end
if comands[comand[1]]then
if comands[comand[1].."level"]<=povolenin then
comands[comand[1]](comand[2],comand[3],comand[4],comand[5],comand[6],comand[7],comand[8],comand[9],comand[10])
else
print("You have too small level for this")
end
end
end
createPartEvent.OnServerEvent:Connect(Cmd)
edit: and kick script
local Players = game:GetService("Players")
local DataStore = game:GetService("DataStoreService"):GetDataStore("pravomoce")
function WhoIsHe (player)
local pravomoc = DataStore:GetAsync(player.userId) or"new"
--print(pravomoc)
GiveHimPremisions(player,pravomoc)
end
function GiveHimPremisions(player,premisionLevel)
if premisionLevel=="ban" then
player:kick("you have ban")
end
end
Scripts like these are allowed, as groups and people have them in their games all of the time. There also is a post on the developer forum asking for “Group Banning Scripts” and it was never said that it’s not allowed, nor was it flagged because it was breaking any rule.
Yes, almost every script is allowed, except scams. group bans must be allowed only for reason, that whan i get the list of members from roblox site HTML (if i know c# its easy to get all members) and i ban every player in the list it is ok because it is normal ban so there is no problem, but if you want to be 100% sure you must read roblox rules
What are you talking about? Group Recruiting Plaza has a script like this.
Why aren’t they allowed? I thought they were.
You should not be using the “others do it” justification ever for a situation involving gray areas with rules as that leads you into all kinds of traps. That being said, while banning other groups is not explicitly disallowed, it’s heavily frowned upon the same way banning based on a player’s AccountAge property is.
All in all, recommending OP to stay away from that is an unwarranted opinion and doesn’t belong here. Please focus on answering the question at hand, which is to set up a permanent ban system.
@xWil_l Your code samples including or statements are all incorrect. Players would end up getting banned. All your operands after the first one will evaluate to true. You must explicitly write equality checks in each operand.
You also made a mistake in your second example where you checked a Player’s name against their UserId.
if false or "yes" then
print("This will pass. Yes is a string, which is valid.")
end
if false or true then
print("This is basically what your code is doing.")
end
This is the proper way to write each of those if statements (I only did up to two operands so you get the gist, don’t want to write everything out because this is a horrible way of handling special actions for users meeting a certain criteria):
if Player.Name == "Roblox" or Player.Name == "Templates" then
if Player.UserId == 2394723 or Player.UserId == 1 then