Advertisement
ohusq

Untitled

Mar 5th, 2023
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. local DataStoreService = game:GetService("DataStoreService")
  2. local Admins = {2773194693} --// ohusq (Owner)
  3. local Commands = {
  4.     ["kill"] = function(Player)
  5.         --// Kill All Players
  6.         print("Killing:", Player)
  7.  
  8.         if Player == "others" then
  9.             for _, Player in pairs(game.Players:GetPlayers()) do
  10.                 if Player ~= game.Players.LocalPlayer then
  11.                     Player.Character.Humanoid.Health = 0
  12.                 end
  13.             end
  14.             return --// Return to prevent the rest of the code from running
  15.         end
  16.         Player.Character.Humanoid.Health = 0
  17.     end,
  18.     ["kick"] = function(Player)
  19.         Player:Kick("You have been kicked from this server.")
  20.     end,
  21.     ["ban"] = function(Player)
  22.         Player:Kick("You have been banned from this game.")
  23.     end
  24. }
  25. local BanList = DataStoreService:GetDataStore("BannedPlayers")
  26. local Prefix = "."
  27.  
  28. game.Players.PlayerAdded:Connect(function(Player)
  29.  
  30.     --// Check if player is banned
  31.     local Success, Banned = pcall(function()
  32.         return BanList:GetAsync(Player.UserId)
  33.     end)
  34.  
  35.     if Success and Banned then
  36.         Player:Kick("You have been banned from this game.")
  37.     end
  38.  
  39.     --// Check if player is admin
  40.     local IsAdmin = false
  41.  
  42.     if table.find(Admins, Player.UserId) then
  43.         IsAdmin = true
  44.     else
  45.         IsAdmin = false
  46.     end
  47.  
  48.     --// Admin commands with prefix (.)
  49.     Player.Chatted:Connect(function(Message)
  50.         if IsAdmin then
  51.             local Args = string.split(Message, " ")
  52.             local Command = Args[1]
  53.             local Target = Args[2]
  54.  
  55.             if string.sub(Command, 1, 1) == Prefix then
  56.                 Command = string.sub(Command, 2)
  57.                 if Commands[Command] then
  58.                     if Target then
  59.                         local TargetPlayer = game.Players:FindFirstChild(Target)
  60.                         if TargetPlayer then
  61.                             Commands[Command](TargetPlayer)
  62.                         end
  63.                     else
  64.                         Commands[Command](Player)
  65.                     end
  66.                 end
  67.             end
  68.         end
  69.     end)
  70. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement