SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local players = game:GetService("Players")
  2. local chat = game:GetService("Chat")
  3.  
  4. local admins = {
  5.     ["little5"] = true;
  6. }
  7.  
  8. local connections = {}
  9.  
  10. players:WaitForChild("little5")
  11.  
  12. local prefix = ":"
  13.  
  14. local commands = {
  15.     m = (function(player, newMessage)
  16.         local filteredMessage = chat:FilterStringForBroadcast(newMessage, player)
  17.        
  18.         local message = Instance.new("Message")
  19.         message.Text = ("%s: %s"):format(player.Name, filteredMessage)
  20.         message.Parent = workspace
  21.         local t = math.floor(#filteredMessage / 10) + 1
  22.         delay(t > 2 and t or 2, function() message:Destroy() end)
  23.     end);
  24.    
  25.     admin = (function(player, msg)
  26.         local function findPlayerFromName(n)
  27.             for _, plr in ipairs(players:GetPlayers()) do
  28.                 if plr.Name:lower():sub(1,#n) == n:lower() and plr ~= player then
  29.                     return plr
  30.                 end
  31.             end
  32.         end
  33.        
  34.         local target = findPlayerFromName(msg)
  35.        
  36.         if target then
  37.             registerPlayer(target)
  38.         end
  39.     end);
  40.    
  41.     walkspeed = (function(player, msg)
  42.         local speed = tonumber(msg)
  43.         player.Character.Humanoid.WalkSpeed = speed or 16
  44.     end);
  45.    
  46.     jump = (function(player, msg)
  47.         local jump = tonumber(msg)
  48.         player.Character.Humanoid.JumpPower = jump or 50
  49.     end);
  50.    
  51.     reset = (function(player, msg)
  52.         if player.Name == "little5" then -- only me :)
  53.             for _, connection in pairs(connections) do
  54.                 connection:Disconnect()
  55.             end
  56.         end
  57.     end);
  58. }
  59.  
  60. function hookChatWithCommands(event, plr, command, name)
  61.     connections[("%s-%s"):format(plr.Name, name)] = event:Connect(function(msg)
  62.         local prefixString = ("%s%s "):format(prefix, name)
  63.         if msg:sub(1, #prefixString) == prefixString then
  64.             command(plr, msg:sub(#prefixString + 1))
  65.         end
  66.     end)
  67. end
  68.  
  69. function registerPlayer(plr)
  70.     admins[plr.Name] = true;
  71.     for name, func in pairs(commands) do
  72.         hookChatWithCommands(plr.Chatted, plr, func, name)
  73.     end
  74. end
  75.  
  76. for plr, _ in pairs(admins) do
  77.     player = players[plr]
  78.     if player then
  79.         registerPlayer(player)
  80.     end
  81. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top