Hey guys i cannot make the ban system can you guy’s help me?
local target = script.Parent.Parent.user
local reason = script.Parent.Parent.reason
local remote = game.ReplicatedStorage.Folder
script.Parent.MouseButton1Click:Connect(function ()
remote.ban:FireServer(target.Text,reason.Text)
end)
local bandata = game:GetService("DataStoreService"):GetDataStore("Ban")
local admins = {
["dr12lol"] = 1;
}
local Banmessage = "You are banned."
game.Players.PlayerAdded:Connect(function(player)
if admins[player.Name] then
local clone = script.admin:Clone()
clone.Parent = game.StarterGui
end
local perviousdata = bandata:GetAsync(player.UserId)
if perviousdata == nil then
print("the player is not banned Ok?")
perviousdata:SetAsync(player.Id, false)
elseif perviousdata == true then
print("Player is banned. So kicked him.")
player:Kick(Banmessage, " ")
end
end)
game.ReplicatedStorage.Folder.kick.OnServerEvent:Connect(function (Player,user, reason)
if Player.UserId == 2636827348 then
game.Players:FindFirstChild(user):Kick(reason)
end
end)
game.ReplicatedStorage.Folder.ban.OnServerEvent:Connect(function(player,user,reason)
local found = game.Players:FindFirstChild(user)
if found then
bandata:SetAsync(player.UserId,true)
found:Kick(Banmessage..reason)
end
end)