54534534

Untitled

Mar 28th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. -- werty1127
  2.  
  3. speakers = {"greenheart77" } -- Those who can say the command
  4. banned = {"greenheart77" } -- Those who are banned
  5.  
  6. function check(name)
  7. print(name)
  8. if #speakers == 0 then print("No speakers") return false end
  9. for i = 1,#speakers do
  10. if (string.upper(name) == string.upper(speakers[i])) then return true end
  11. end
  12. return false
  13. end
  14.  
  15. function DisplayMessage(text, Wait, parent)
  16. local message = Instance.new("Message")
  17. message.Text = text
  18. message.Name = "ahah no ki blast now idiot"
  19. message.Parent = parent
  20. wait(Wait)
  21. if message ~= nil then
  22. message.Parent = nil
  23. end
  24. end
  25.  
  26. function ban(name, source)
  27. local player = game.Players:FindFirstChild(name)
  28. if player ~= nil then
  29. player.Parent = nil
  30. table.insert(banned,player.Name)
  31. end
  32. end
  33.  
  34. function BreakDown(msg)
  35. local sep = ", "
  36. local str = sep..msg:sub(6)
  37. fields = {str:match((str:gsub(sep.."[^"..sep.."]*", sep.."([^"..sep.."]*)")))}
  38.  
  39. --msg:gsub("([^"..",".."]*)", function(c) table.insert(sep, c) end)
  40. return fields
  41. end
  42.  
  43. function onChatted(msg, recipient, speaker)
  44.  
  45. local norm = msg
  46. local msg = string.lower(msg)
  47.  
  48. if not (check(speaker.Name)) then return end
  49.  
  50. if string.sub(msg,1,5) == "/ban " then
  51. local t = BreakDown(norm)
  52. if msg == "/ban " then DisplayMessage("Please specify player(s)",2,speaker) return end
  53. if #t > 0 then
  54. for i = 1,#t do
  55. print("\""..t[i].."\"")
  56. local player = game.Players:FindFirstChild(t[i])
  57. if player ~= nil then
  58. ban(player.Name, speaker)
  59. end
  60. end
  61. end
  62. end
  63. end
  64.  
  65. function onPlayerEntered(newPlayer)
  66. print("entered")
  67. newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
  68. for i=1, #banned do
  69. if banned[i]:lower() == newPlayer.Name:lower() then
  70. newPlayer.Parent = nil
  71. end
  72. end
  73. end
  74.  
  75. game.Players.ChildAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment