Hello everyone, I’m writing this post as I’m trying to achieve the goal of creating my own Roblox ban list script, I want this to be a plugin everyone can use to ban known trollers, exploiters and scammers but I’ve tried working on it and I have no idea how to make it work. I’ve tried to use DevHub for some of this but I don’t have much of an idea of what I’m doing. Here is my script:
local Players = game:GetService("Players")
local banlist = {
'John Doe',
'Jane Doe'
}
local function playerjoined(player)
local plrtokick = Players:FindFirstChild(name)
if Players:FindFirstChild(name) = banlist then
plrtokick:Kick('You have been banned from this game for either: exploiting, scamming or trolling.' ..
'Any alternate accounts will be banned as well.' ..
..
"Powered by GamersInternational's Ban List")
end
end
Players.PlayerAdded:Connect('playerjoined')
local banList = {"John","John"}
game.Players.PlayerAdded:Connect(function(player)
for i, v in pairs(banList) do
if player.Name == v then
-- Kick
end
end
end)
Okay some things I want to state out, Use the players UserId instead of the name. They can just change there name.
local BanList = {
-- Someone you dislikes UserId for example
111
}
local function playerjoined(player)
for i,v in pairs(banlist) do -- Doing a loop through the banlist
local success, err = pcall(function() -- If it fails returns "Player isn't on the banlist!"
if player.UserId == v then -- Checks if the userid is on the banlist
player:Kick("Power by GameInternational's antiexploit") -- Kicks player.
else
print("Player isn't on the banlist!") -- Player isn't on the banlist msg
end
end)
end
end
game.Players.PlayerAdded:Connect(playerjoined) -- Use connect to connect a local function
Want to point out that he just scripted what i explained in the 1st reply… Didnt want you to just copy and paste any code. This isnt the right way to learn.
I will use UserID’s on it, just configuring the install script so people do get automatic updates.
Big oof @thosenamesaregood and @HackItsGood, the install script doesn’t work because it’s not a modulescript. We’ll have to stick with serversided for now.
Adding to what @HackItsGood said, you can actually just use table.find() instead of a for loop
local banList = {"John","John"}
game.Players.PlayerAdded:Connect(function(player)
if table.find(banList, player.Name) then
player:Kick("Reason")
end
end)
Just to add to it, you should always use the UserId instead of Name, Name can be changed, UserId cannot. Use UserID for anything that sticks with a player, dataStores, banLists, etc.
So you should actually change it to
local banList = {12309,1764863}
game.Players.PlayerAdded:Connect(function(player)
if table.find(banList, player.UserId) then
player:Kick("Reason")
end
end)