DrawingJhon

Chat all Script

Jun 12th, 2020 (edited)
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.30 KB | None | 0 0
  1. --[[
  2. Script created by: JhonXD2006 (My Roblox username :P)
  3. Chat Commands:
  4. 1- play/name                    <- You write what someone else says with the name included.
  5. 2- play/text                    <- You only write what someone else says.
  6. 3- stop/chat                    <- You won't write anything.
  7. 4- give/<username> or me        <- The name you give will be written in the chat (It needs to be the complete username).
  8. 5- chat/<username> or all       <- Only one player chatted.
  9. 6- //break                      <- Break the script
  10. 7- play/hello
  11. 8- stop/hello
  12.  
  13. Warning: The script won't work in Void Script Builder (for the security of chat).
  14. ]]
  15.  
  16. local playerSpeaker = owner and owner.Name or "JhonXD2006"  -- ur name
  17.  
  18.  
  19. --Comprobation if script already exist
  20.  
  21. if game:findFirstChildOfClass("StarterPlayer").Name ~= "StarterPlayer" then error("Cannot run the script here, please, try another game") end
  22. local hasChat = game:GetService("ReplicatedStorage"):findFirstChild("GameHasChat")
  23. if hasChat then
  24.     if hasChat.Value == true then
  25.         error("The game already has the script working")
  26.     else
  27.         hasChat.Value = true
  28.     end
  29. else
  30.     local p = Instance.new("BoolValue", game:GetService("ReplicatedStorage"))
  31.     p.Name = "GameHasChat"
  32.     p.Value = true
  33. end
  34.  
  35. --The entire script--
  36.  
  37. local Players = game:GetService("Players")
  38. local playerHack = Players:findFirstChild(playerSpeaker)
  39. local ChatService = require(game:GetService("ServerScriptService").ChatServiceRunner.ChatService)
  40. local text = false
  41. local name = false
  42. local speakerExist
  43. local hackerExist
  44. local onePlayer = false
  45. local onePlayerName
  46. local welcome = false
  47.  
  48. ChatService:RegisterProcessCommandsFunction("BlahBlahNOT", function(speakerName, msg, channelName)
  49.     if (text or name) and Players:findFirstChild(speakerName) ~= playerHack then
  50.         return true
  51.     end
  52.     return false
  53. end)
  54.  
  55. local forceDisabled = false
  56.  
  57.  
  58. function Chat(plr, msg)
  59.     local speaker = ChatService:GetSpeaker(plr.Name)
  60.     if not speaker then
  61.         return
  62.     end
  63.     speaker:SayMessage(msg, "All", {})
  64. end
  65.  
  66. local function onChatted(player)
  67.     if player.Name == playerSpeaker then
  68.         speakerExist = true
  69.     end
  70.     if player == playerHack then
  71.         hackerExist = true
  72.     end
  73.     player.Chatted:Connect(function(message)
  74.         if speakerExist == true or hackerExist == true then
  75.             if forceDisabled == false then -- Force Disabled Start
  76.                 if name == true and player ~= playerHack and onePlayer == false then
  77.                     local m = message:sub(1)
  78.                     Chat(playerHack, "["..player.Name.."]: "..m)
  79.                 elseif name == true and onePlayer == true then
  80.                     if player == onePlayerName then
  81.                         local m = message:sub(1)
  82.                         Chat(playerHack, "["..player.Name.."]: "..m)
  83.                     end
  84.                 end
  85.                 if text == true and player ~= playerHack and onePlayer == false then
  86.                     local m = message:sub(1)
  87.                     Chat(playerHack, m)
  88.                 elseif text == true and onePlayer == true then
  89.                     if player == onePlayerName then
  90.                         local m = message:sub(1)
  91.                         Chat(playerHack, m)
  92.                     end
  93.                 end
  94.                 if message:lower() == "stop/chat" and player.Name == playerSpeaker then
  95.                     name = false
  96.                     text = false
  97.                     welcome = false
  98.                 end
  99.                 if message:lower() == "play/name" and player.Name == playerSpeaker then
  100.                     name = true
  101.                     text = false
  102.                 end
  103.                 if message:lower() == "play/text" and player.Name == playerSpeaker then
  104.                     text = true
  105.                     name = false
  106.                 end
  107.                 if message:sub(1,5) == "give/" and player.Name == playerSpeaker then
  108.                     for i, v in pairs(game.Players:GetChildren()) do
  109.                         if v.Name == message:sub(6) then
  110.                             playerHack = v
  111.                         end
  112.                     end
  113.                 end
  114.                 if message:lower() == "give/me" and player.Name == playerSpeaker then
  115.                     playerHack = game.Players:findFirstChild(playerSpeaker)
  116.                 end
  117.                 if message:sub(1,5) == "chat/" and player.Name == playerSpeaker then
  118.                     for i, z in pairs(game.Players:GetChildren()) do
  119.                         if z.Name == message:sub(6) then
  120.                             onePlayer = true
  121.                             onePlayerName = z
  122.                         end
  123.                     end
  124.                 end
  125.                 if message:lower() == "chat/all" and player.Name == playerSpeaker then
  126.                     onePlayer = false
  127.                 end
  128.                 if message:lower() == "//break" and player.Name == playerSpeaker then
  129.                     warn("The script is disabled and will no longer be usable.")
  130.                     forceDisabled = true
  131.                     hasChat.Value = false
  132.                 end
  133.                 if message:lower() == "play/hello" and player.Name == playerSpeaker then
  134.                     welcome = true
  135.                 end
  136.                 if message:lower() == "stop/hello" and player.Name == playerSpeaker then
  137.                     welcome = false
  138.                 end
  139.             end -- Force Disabled end
  140.         end
  141.     end)
  142. end
  143.  
  144. Players.PlayerAdded:Connect(function(player)
  145.     onChatted(player)
  146.     if welcome == true and forceDisabled == false and hackerExist == true then
  147.         local welcomeMessage = "Hi, "..player.Name.."!"
  148.         Chat(playerHack, welcomeMessage)
  149.     end
  150. end)
  151. for i, v in pairs(Players:GetChildren()) do
  152.     onChatted(v)
  153. end
  154.  
  155. Players.PlayerRemoving:Connect(function(player)
  156.     if player.Name == playerSpeaker then
  157.         speakerExist = false
  158.     end
  159.     if player == playerHack and speakerExist == true then
  160.         playerHack = game.Players:findFirstChild(playerSpeaker)
  161.     elseif player == playerHack and speakerExist == false then
  162.         hackerExist = false
  163.     end
  164.     if player == onePlayerName then
  165.         onePlayer = false
  166.     end
  167.     if welcome == true and forceDisabled == false and hackerExist == true then
  168.         local byeMessage = "Bye, "..player.Name.."!"
  169.         Chat(playerHack, byeMessage)
  170.     end
  171. end)
  172. -- lol
Add Comment
Please, Sign In to add comment