LawMixer

TbanServer

Aug 3rd, 2021 (edited)
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.97 KB | None | 0 0
  1. local Players = game:GetService("Players");
  2. local DatastoreService = game:GetService("DataStoreService");
  3.  
  4.  
  5. -- setting up the database
  6. local BanDatabase = DatastoreService:GetDataStore("InDevelopmentTesting")
  7. local AmTimeStorage = BanDatabase:GetAsync("TimeLeft")
  8. local PastBanTimes = BanDatabase:GetAsync("isBanned", false);
  9. local ReasonStorage = BanDatabase:GetAsync("Reason");
  10. local bantime = 0
  11.  
  12.  
  13. function checkBan(pl, length, reason)
  14.     local UserDatabase = BanDatabase:GetAsync(pl.Name .. "_TempBan")
  15.    
  16.     if length == "0 hours" then
  17.         UserDatabase:UpdateAsync("isBanned", false)
  18.         UserDatabase:UpdateAsync("Reason", nil)
  19.         UserDatabase:UpdateAsync("timeLeft", 0)
  20.     end
  21.    
  22.     if length == "12 hours" then
  23.         UserDatabase:UpdateAsync("isBanned", true)
  24.         UserDatabase:UpdateAsync("Reason", reason)
  25.         UserDatabase:UpdateAsync("timeLeft", 12)
  26.         game.Players:FindFirstChild(pl):Kick("You have been temporarily banned from the game.\nReason: "..reason);
  27.     end
  28.    
  29.     if length == "24 hours" then
  30.         UserDatabase:UpdateAsync("isBanned", true)
  31.         UserDatabase:UpdateAsync("Reason", reason)
  32.         UserDatabase:UpdateAsync("timeLeft", 24)
  33.         game.Players:FindFirstChild(pl):Kick("You have been temporarily banned from the game.\nReason: "..reason);
  34.     end
  35.    
  36.     if length == "48 hours" then
  37.         UserDatabase:UpdateAsync("isBanned", true)
  38.         UserDatabase:UpdateAsync("Reason", reason)
  39.         UserDatabase:UpdateAsync("timeLeft", 48)
  40.         game.Players:FindFirstChild(pl):Kick("You have been temporarily banned from the game.\nReason: "..reason);
  41.     end
  42.  
  43.     if length == "72 hours" then
  44.         UserDatabase:UpdateAsync("isBanned", true)
  45.         UserDatabase:UpdateAsync("Reason", reason)
  46.         UserDatabase:UpdateAsync("timeLeft", 72)
  47.         game.Players:FindFirstChild(pl):Kick("You have been temporarily banned from the game.\nReason: "..reason);
  48.     end
  49. end
  50.  
  51.  
  52.  
  53. return function (context, userid, reason)
  54.     game.Players.PlayerAdded:Connect(function()
  55.         checkBan()
  56.     end)
  57.  
  58.     return ("Successfully banned".. userid .. "for");
  59. end
Add Comment
Please, Sign In to add comment