Advertisement
DarkusBlox

Roblox new Ban API - BanAsync(), UnbanAsync()

Jun 26th, 2024
1,080
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | Source Code | 0 0
  1. -- Requires 2 parts on workspace with the names "BanPart" and "UnbanPart"
  2.  
  3. local Players = game:GetService("Players")
  4. local BanPart = workspace:FindFirstChild("BanPart")
  5. local UnbanPart = workspace:FindFirstChild("UnbanPart")
  6.  
  7. BanPart.Touched:Connect(function(hit)
  8.     if hit.Parent:FindFirstChild("Humanoid") then
  9.         local player = Players:GetPlayerFromCharacter(hit.Parent)
  10.        
  11.         local config = {
  12.             UserIds = {player.UserId}, -- User/s to ban
  13.             ApplyToUniverse = true, -- Does the user get banned from all places connected to this experience or only this place.
  14.             Duration = -1, -- Ban Duration (In seconds) -1 = permanent ban
  15.             DisplayReason = "You have been banned for using exploits.", -- Ban Message to the player
  16.             PrivateReason = "Banned using exploits", -- Private Reason for u
  17.             ExcludeAltAccounts = false -- Do you want this player to get their alt accounts banned too? - false = no
  18.         }
  19.        
  20.         local success, err = pcall(function()
  21.             Players:BanAsync(config)
  22.         end)
  23.         print(success, err)
  24.     end
  25. end)
  26.  
  27. UnbanPart.Touched:Connect(function(hit)
  28.     if hit.Parent:FindFirstChild("Humanoid") then
  29.         local config = {
  30.             UserIds = {146640776}, -- Player/s to unban
  31.             ApplyToUniverse = true -- Unban from current place or all places connected to the game
  32.         }
  33.        
  34.         local success, err = pcall(function()
  35.             Players:UnbanAsync(config)
  36.         end)
  37.        
  38.         if success then
  39.             print("Player has been unbanned successfuly!")
  40.         else
  41.             print(err)
  42.         end
  43.     end
  44. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement