How Make a Script Ban System

Credits

dukzae - Comment that helped us: I would recommend putting your code in the Lua format so it is easier to read.

local hello = game.Workspace

Tutorial

Hey guys! This is my first tutorial on the DevForum, so please do not expect it to be as amazing as you would expect from a experienced developer.

So first, what you want to do is a create a new Script inside of “ServerScriptService”, name it whatever you want!

Now what we want to do is creating a new table, that will store all our bans:

local Banned = {“someoneuhate”}
Now what we want to do is to make it so when the player joins, we will execute a function.
game.Players.PlayerAdded:Connect(function(player)
Now, do enter, should looks like this:
game.Players.PlayerAdded:Connect(function(player)

end)

Inside of our function we want to check if the player is in our banned table:
if table.find(Banned, player.Name) then

end)

Now you want to disconnect the player in the table we just created from the server:
if table.find(Banned, player.Name) then
player:Kick()

end)

You also want to destroy them so they don’t change there kick message.
if table.find(Banned, player.Name) then
player:Kick()
wait(2)
player:Destroy()
end
Now enjoy your ban system to keep these hackers out!

Full script:

local Banned = {“ROBLOX”}

game.Players.PlayerAdded:Connect(function(player)
if table.find(Banned, player.
Name) then
player:Kick()
wait(2)
player:Destroy()
end)
end

Suggestions are appreciated by posting, the level of Member+ only can post

5 Likes

I would recommend putting your code in the Lua format so it is easier to read.

local hello = game.Workspace
2 Likes

Thank you for the tutorial, however I’ll just use HD admin. (I might use this)

2 Likes

How exactly do I do? I’m new at the DevForum, I got promoted like today.

1 Like

No problem! Don’t hesitate to give me feedbacks so I can improve!

2 Likes

alright that didn’t work, basically you have to use these three characters ``` followed by “lua” (without the quotations) and then write the code. when you have finished writing the code, put another of those three characters.

if that didn’t make any sense, try making a draft in the Scripting Support category; it gives you a template automatically

Hello, and what about unbanning? this is something really complex to do :confused:

1 Like

It’s (probably) as simple as removing the player from the “banned” table

Remove them from the banned table. :grinning: