Advertisement
3DCreator

commandhandler

Dec 22nd, 2024
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local datastore = game:GetService("DataStoreService")
  2. local players = game:GetService("Players")
  3. local serverstorage = game:GetService("ServerStorage")
  4.  
  5. local modules = serverstorage.modules
  6. local commands = serverstorage.commands
  7.  
  8. local whitelists = require(modules.whitelists)
  9. local admindata = datastore:GetDataStore("admins")
  10. local bandata = datastore:GetDataStore("bans")
  11.  
  12. _G.fetchplayer = modules.fetchtarget
  13. _G.sban = {}
  14.  
  15. players.PlayerAdded:Connect(function(player)
  16.     local banned = bandata:GetAsync(player.UserId)
  17.     if banned and banned[1] == true then
  18.         player:Kick("You are banned for"..banned[2]..".")
  19.     end
  20.    
  21.     if table.find(_G.sban, player.UserId) then
  22.         player:Kick("You are server banned.")
  23.     end
  24.    
  25.     if table.find(whitelists, player.UserId) or admindata:GetAsync(player.UserId) == true then
  26.         player.Chatted:Connect(function(message)
  27.             local arguments = message:split(" ")
  28.             if arguments[1]:find("/") then
  29.                 local command = commands:FindFirstChild(arguments[1]:gsub("/", ""):lower())
  30.                 if command then
  31.                     require(command).run(player, message, arguments)
  32.                 end
  33.             end
  34.         end)
  35.     end
  36. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement