9_cVv

chat bot

Dec 1st, 2020 (edited)
1,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.61 KB | None | 0 0
  1. local plrs = game:GetService("Players")
  2. local runService = game:GetService("RunService")
  3. local localPlayer = plrs.LocalPlayer
  4. repeat wait() until game.ReplicatedStorage:FindFirstChild("DefaultChatSystemChatEvents")
  5. local event = game.ReplicatedStorage.DefaultChatSystemChatEvents.SayMessageRequest
  6. local cmds = "TechHog's Chat-Bot commands are :say, leaderstats, cmdlist, friends, friendcount, jumpspersecond, joindate, plrlist, speed, jumppower. How to use TechHog's Chat-Bot: type /unmute command player and press enter. For speed and jumppower, type /unmute command ammount and press enter."
  7.  
  8. local function getfriends(userId)
  9.     local function iterPageItems(pages)
  10.         return coroutine.wrap(function()
  11.             local pagenum = 1
  12.             while true do
  13.                 for _, item in ipairs(pages:GetCurrentPage()) do
  14.                     coroutine.yield(item, pagenum)
  15.                 end
  16.                 if pages.IsFinished then
  17.                     break
  18.                 end
  19.                 pages:AdvanceToNextPageAsync()
  20.                 pagenum = pagenum + 1
  21.             end
  22.         end)
  23.     end
  24.  
  25.     local friendPages = plrs:GetFriendsAsync(userId)
  26.     local usernames = {}
  27.     for item, pageNo in iterPageItems(friendPages) do
  28.         table.insert(usernames, item.Username)
  29.     end
  30.     return usernames
  31. end
  32. local function command(player,comand,second, third)
  33.     for i,target in pairs(plrs:GetPlayers()) do
  34.         if string.match(target.Name, second, third) then
  35.             comand(target)
  36.         end
  37.     end
  38. end
  39.  
  40. local function leaderstats(target)
  41.     if target:FindFirstChild("leaderstats") then
  42.         event:FireServer(target.Name..'s leaderstats are:','All')
  43.         for a,stat in pairs(target.leaderstats:GetChildren()) do
  44.             event:FireServer('Name: '..tostring(stat.name..'. ')..'Value: '..tostring(stat.Value..'. '),'All')
  45.         end
  46.     end
  47. end
  48. local function friends(target)
  49.     local usernames = getfriends(target.UserId)
  50.     local targetFriends = ''
  51.     for a,user in pairs(usernames) do
  52.         targetFriends = targetFriends .. user
  53.     end
  54.     event:FireServer(target.Name..'s friends are: '..tostring(targetFriends),'All')
  55. end
  56. local function friendcount(target)
  57.     local frens = 0
  58.     local usernames = getfriends(target.UserId)
  59.     for a,user in pairs(usernames) do
  60.         frens = frens + 1
  61.     end
  62.     event:FireServer(target.Name..' has '..tostring(frens)..' friends!','All')
  63. end
  64. local function joindate(target)
  65.     local day = 60 * 60 * 24
  66.     local tm = os.time() - (day * target.AccountAge)
  67.     local date = os.date("!*t", tm)
  68.  
  69.     event:FireServer(target.Name..'s join date is: ' .. date.month.. 'm-' .. date.day .. 'd-' .. date.year .. 'y','All')
  70. end
  71. local function jumpspersecond(target)
  72.     if target:FindFirstChild("leaderstats") then
  73.         if target.leaderstats:FindFirstChild("Jumps") then
  74.             local jumps = target.leaderstats.Jumps
  75.             local jumpsValue1 = jumps.Value
  76.             wait(1)
  77.             local jumpsValue2 = jumps.Value
  78.             local jps = jumpsValue2-jumpsValue1
  79.             event:FireServer('Wow! '..target.Name..' is jumping '..tostring(jps)..' jumps per second!','All')
  80.         end
  81.     end
  82. end
  83. local function speed(target, speed)
  84.     if target.Character then
  85.         target.Character:WaitForChild("Humanoid").WalkSpeed = tonumber(speed)
  86.     end
  87. end
  88. local function jumppower(target, jumppower)
  89.     if target.Character then
  90.         target.Character:WaitForChild("Humanoid").JumpPower = tonumber(jumppower)
  91.     end
  92. end
  93.  
  94. for a,human in pairs(game:GetService("Players"):GetPlayers()) do
  95.     human.Chatted:connect(function(msg)
  96.         local args = string.split(msg,' ')
  97.         if args[1] == '/unmute' then
  98.             if args[2] == 'say' then
  99.                 event:FireServer(tostring(string.sub(msg, string.len(args[1]) + string.len(args[2]) + 2)),'All')
  100.             end
  101.             if args[2] == 'cmdlist' then
  102.                 event:FireServer(cmds, 'All')
  103.             end
  104.             if args[2] == 'leaderstats' then
  105.                 command(localPlayer,leaderstats,args[3])
  106.             end
  107.             if args[2] == 'friends' then
  108.                 command(localPlayer,friends,args[3])
  109.             end
  110.             if args[2] == 'friendcounter' then
  111.                 command(localPlayer,friendcount,args[3])
  112.             end
  113.             if args[2] == 'joindate' then
  114.                 command(localPlayer,joindate,args[3])
  115.             end
  116.             if args[2] == 'jumpspersecond' then
  117.                 command(localPlayer,jumpspersecond,args[3])
  118.             end
  119.             if args[2] == 'plrlist' then
  120.                 local plrlist = ''
  121.                 for a,target in pairs(plrs:GetPlayers()) do
  122.                     plrlist = plrlist..' '..target.Name
  123.                 end
  124.                 event:FireServer('Players in the game include: '..plrlist,'All')
  125.             end
  126.             if args[2] == 'plrcount' then
  127.                 local plrcount = 0
  128.                 for a,target in pairs(plrs:GetPlayers()) do
  129.                     plrcount = plrcount + 1
  130.                 end
  131.                 event:FireServer('There are '..tostring(plrcount)..' players in     this game!','All')
  132.             end
  133.             if args[2] == 'speed' then
  134.                 speed(localPlayer, args[3])
  135.             end
  136.             if args[2] == 'jumppower' then
  137.                 jumppower(localPlayer, args[3])
  138.             end
  139.         end
  140.     end)
  141. end
Add Comment
Please, Sign In to add comment