The title is self explanatory, my ban command won’t work.
local Datastore = game:GetService("DataStoreService")
local BanDatastore = Datastore:GetDataStore("Ukip18414194180149915015910150151")
local Settings = require(game:GetService("ServerScriptService").ModerationPackageV1.Modules.Settings)
local PlrService = game:GetService("Players")
local function GetPlayer(String)
for i,v in pairs(game.Players:GetPlayers()) do
if (string.sub(string.lower(v.Name), 1, string.len(String))) == string.lower(String) then
return v
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
if BanDatastore:GetAsync(plr.UserId,true) and not table.find(Settings.Admins, plr.UserId) then
plr:Kick("You are banned")
else
if table.find(Settings.Admins, plr.UserId) then
plr.Chatted:Connect(function(msg)
local arg = msg:split(" ")
if string.lower(msg) == Settings.prefix.."ban" then
if arg[2] then
local target = GetPlayer(arg[2])
local ID = target.UserId
if table.find(Settings.Admins, ID) then return warn("Cannot ban a admin") end
local Success, ErrorMessage = pcall(function()
BanDatastore:SetAsync(ID,true)
end)
if Success then
target:Kick("The ban hammer has spoken!")
else
error(ErrorMessage)
end
end
end
end)
end
end
end)