local DatastoreService = game:GetService("DataStoreService")
local ds = DatastoreService:GetDataStore("BanList")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local event1 = ReplicatedStorage.AdminGui:WaitForChild("Ban")
local event2 = ReplicatedStorage.AdminGui:WaitForChild("Unban")
local Players = game:GetService("Players")
local webhook = ""
local HttpService = game:GetService("HttpService")
local admins = {
"MythsList",
"kindHeartedDa"
}
local bannedpeople = {}
ds:GetAsync(bannedpeople)
game.Players.PlayerAdded:Connect(function(plr)
--ds:GetAsync(plr.UserId, bannedpeople)
if table.find(bannedpeople, plr.UserId) then
wait(0.2)
plr:Kick("You are permanently banned from the game.")
print("autoban")
end
end)
local function Banned(admin, username, reason)
local bannedplayer = Players:FindFirstChild(username)
for i = 1, #admins do
if admin.Name == admins[i] then
if bannedplayer ~= nil then
bannedplayer:Kick(reason)
table.insert(bannedpeople, bannedplayer.UserId)
ds:SetAsync(bannedplayer.UserId, bannedpeople)
local data = {
['embeds'] = {{
['title'] = "Username : "..username,
['description'] = "Reason : "..reason,
['color'] = 0
}}
}
local finalData = HttpService:JSONEncode(data)
HttpService:PostAsync(webhook, finalData)
print("banned")
end
end
end
end
local function Unbanned(admin, username, reason)
local unbannedplayer = Players:FindFirstChild(username)
for i = 1, #admins do
if admin.Name == admins[i] then
if unbannedplayer ~= nil then
if table.find(bannedpeople, unbannedplayer.UserId)then
table.remove(bannedpeople, table.find(bannedpeople, unbannedplayer.UserId))
ds:SetAsync(unbannedplayer.UserId, bannedpeople)
local data = {
['embeds'] = {{
['title'] = "Username : "..username,
['description'] = "Reason : "..reason,
['color'] = 0
}}
}
local finalData = HttpService:JSONEncode(data)
HttpService:PostAsync(webhook, finalData)
print("unbanned")
end
end
end
end
end
event1.OnServerEvent:Connect(Banned)
event2.OnServerEvent:Connect(Unbanned)
I still have problems with this
ds is the datastore
