How to make Ban Script

##NOTICE##
Please remove the " From the banned players script part to make it work I made this script outside of studio. Feel free to re-copy and paste this script as I fixed it for you.
STEP ONE
Create and Script

STEP TWO
Paste this script below

--UserId of the players you want to kick
local players = (123, 1234)
--Add your own ban message
local message = "Banned"
--Add your own ban reason
local reason = " | Reason: Server owner has banned you for unknown reason"

--Basic Programming for the server to kick them
game.Players.PlayerAdded:Connect(function(player)
for _, v in pairs(players) do
if player.UserId == v then
player:Kick(message,reason)
end
end
end)

STEP THREE
Add UserID’s into for them to be banned

local players = (123, 1234)

Let’s say I want to ban ROBLOX. ROBLOX’s UserID is 1 so I would add it to the script and it would look like this.

local players = (123, 1234, 1)

Let’s say I also want to ban Builderman also, The script would look like this then.

local players = (123, 1234, 1, 156)

In order to get player’s userid Head to there profile.


You can find the userId here highlighted in blue

156 Is buildermans User ID.

3 Likes

This topic was automatically closed after 1 minute. New replies are no longer allowed.