Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local DDS = game:GetService("DataStoreService");
- local pname = game.Players.LocalPlayer.Name;
- local Players = game:GetService("Players");
- local BanStore = DDS:GetDataStore("BanStore", 2);
- local secondsInADay = 86400
- local function SetBan(Player, Reason, Duration)
- local Success, Error = pcall(function()
- BanStore:SetAsync(tostring(Player.UserId), {BanStart = os.time(), BanDuration = (Duration * secondsInADay), BanReason = Reason});
- end)
- Player:Kick(Reason);
- if not Success then
- warn("Not successful.")
- end
- end
- local function GetBan(Player)
- local Success, Result = pcall(function()
- return BanStore:GetAsync(tostring(Player.UserId), "TempBan");
- end)
- if Success then
- if Result then
- if Result.BanStart + Result.BanDuration > os.time() then
- return nil;
- else
- return Result.BanReason;
- end
- end
- end
- end
- Players.PlayerAdded:Connect(function(plr)
- local IsBanned = GetBan(plr);
- if IsBanned ~= nil then
- plr:Kick(IsBanned);
- else
- print("Player's ban has been lifted.");
- end
- if plr.UserId == game.CreatorId then
- plr.Chatted:Connect(function(message)
- if string.sub(message, 1, #"/ban"):lower() == "/ban" then
- local args = string.split(message, " ");
- local numbers = "%d" or "%d%d";
- local duration = string.sub(message, string.find(message, numbers));
- local playerToBan = Players:FindFirstChild(args[2])
- local reason = string.sub(message, string.len("/ban " .. args[2] .. " " .. duration) + 1);
- if playerToBan then
- if duration then
- if reason then
- SetBan(playerToBan, reason, duration);
- print("Player has been banned!");
- end
- end
- end
- end
- end)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment