Advertisement
GaryScripts

admin script

Aug 5th, 2021
1,259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. local commands = {}
  2. local prefix = ":"
  3.  
  4. local admins = {
  5.     "kurtfan5468"
  6. }
  7.  
  8. local function findP(v)
  9.     for i, p in ipairs(game.Players:GetPlayers()) do
  10.         if string.lower(p.Name) == v then
  11.             return p
  12.         end
  13.     end
  14.    
  15.     return nil
  16. end
  17.  
  18. local function isAdmin(p)
  19.     for _, v in ipairs(admins) do
  20.         if v == p.Name then
  21.             return true
  22.         end
  23.     end
  24.    
  25.     return false
  26. end
  27.  
  28. commands.tp = function(sender, args)
  29.     print("function fired")
  30.    
  31.     for _, v in ipairs(args) do
  32.         print(v)
  33.     end
  34.    
  35.     local PTTN = args[1]
  36.     local PTTTN = args[2]
  37.    
  38.     if PTTN and PTTTN then
  39.         local PTT = findP(PTTN)
  40.         local PTTT = findP(PTTTN)
  41.        
  42.         if PTT and PTTT then
  43.             PTT.Character.HumanoidRootPart.CFrame = PTTT.Character.HumanoidRootPart.CFrame
  44.             print("successfully moved")
  45.         end
  46.     end
  47. end
  48.  
  49. commands.sp = function(sender, args)
  50.     print("speed func fired")
  51.    
  52.     local PTGST = args[1]
  53.     local AOSTG = args[2]
  54.    
  55.     if PTGST then
  56.         local plr = findP(PTGST)
  57.        
  58.         if plr then
  59.             plr.Character.Humanoid.Walkspeed = tonumber(AOSTG)
  60.             print("gave speed to: "..plr.Name)
  61.         end
  62.     end
  63. end
  64.  
  65. game.Players.PlayerAdded:Connect(function(p)
  66.     p.Chatted:Connect(function(msg, recip)
  67.         if isAdmin(p) then
  68.             msg = string.lower(msg)
  69.  
  70.             local split = msg:split(" ")
  71.             local slashCmd = split[1]
  72.             local cmd = slashCmd:split(prefix)
  73.             local cmdName = cmd[2]
  74.  
  75.             if commands[cmdName] then
  76.                 local args = {}
  77.                 for i = 2, #split, 1 do
  78.                     table.insert(args, split[i])
  79.                 end
  80.  
  81.                 commands[cmdName](p, args)
  82.             end
  83.         end
  84.     end)
  85. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement