Advertisement
DrawingJhon

Copy Messages Tool

Aug 23rd, 2022 (edited)
838
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local UIS = game:GetService("UserInputService")
  3. local StarterGui = game:GetService("StarterGui")
  4. local CoreGui = game:GetService("CoreGui")
  5. local Players = game:GetService("Players")
  6. local LocalPlayer = Players.LocalPlayer
  7. local Mouse = LocalPlayer:GetMouse()
  8. local Chat = game:GetService("Chat")
  9.  
  10. function PlayerChatted(func, fromChat)
  11.     if fromChat then
  12.         return Chat.Chatted:Connect(function(obj, message)
  13.             local player = Players:GetPlayerFromCharacter(obj)
  14.             if player then
  15.                 func(player, message)
  16.             end
  17.         end)
  18.     else
  19.         local ChatEvents = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents", math.huge)
  20.         local MessageEvent = ChatEvents:WaitForChild("OnMessageDoneFiltering", math.huge)
  21.         local SpeakEvent = ChatEvents:WaitForChild("SayMessageRequest", math.huge)
  22.        
  23.         return MessageEvent.OnClientEvent:Connect(function(data)
  24.             if data ~= nil then
  25.                 local speakerName = data.FromSpeaker
  26.                 local message = data.Message
  27.                 local player = nil
  28.                 for i, v in pairs(Players:GetPlayers()) do
  29.                     if v.Name:lower() == speakerName:lower() then
  30.                         player = v
  31.                     end
  32.                 end
  33.                 if player then
  34.                     func(player, message)
  35.                 end
  36.             end
  37.         end)
  38.     end
  39. end
  40.  
  41. function Speak(message)
  42.     game:GetService("ReplicatedStorage").Packages.Knit.Services.RadioService.RF.SendMessage:InvokeServer(message)
  43.  
  44.     --SpeakEvent:FireServer(message, "All")
  45. end
  46.  
  47. local Target = nil
  48.  
  49. local Gui = Instance.new("ScreenGui")
  50. Gui.Name = math.random()
  51. Gui.Parent = CoreGui
  52.  
  53. local Hint = Instance.new("TextLabel", Gui)
  54. Hint.AnchorPoint = Vector2.new(0.5, 1)
  55. Hint.Position = UDim2.new(0.5, 0, 1, -70)
  56. Hint.Size = UDim2.new(0, 250, 0, 30)
  57. Hint.BackgroundTransparency = 0.6
  58. Hint.BackgroundColor3 = Color3.new(0, 0, 0)
  59. Hint.TextColor3 = Color3.new(0.7, 0.7, 0.7)
  60. Hint.TextSize = 16
  61. Hint.Font = "Arial"
  62. Hint.BorderSizePixel = 0
  63. Hint.Text = "No one"
  64.  
  65. local Tool = Instance.new("Tool", LocalPlayer:FindFirstChildOfClass("Backpack"))
  66. Tool.Name = "Replicate Messages"
  67. Tool.RequiresHandle = false
  68. Tool.CanBeDropped = false
  69.  
  70. local activated = UIS.InputBegan:Connect(function(input)
  71.     if not (input.UserInputType == Enum.UserInputType.MouseButton1 and Tool.Parent == LocalPlayer.Character) then
  72.         return
  73.     end
  74.     local hit = Mouse.Target
  75.     local player = Players:GetPlayerFromCharacter(hit.Parent)
  76.     Target = player
  77.     if player then
  78.         Hint.Text = player.Name
  79.         Hint.TextColor3 = Color3.new(1, 1, 1)
  80.     else
  81.         Hint.Text = "No one"
  82.         Hint.TextColor3 = Color3.new(0.7, 0.7, 0.7)
  83.     end
  84. end)
  85.  
  86. local chatted = PlayerChatted(function(player, message)
  87.     if player == Target then
  88.         Speak(message)
  89.     end
  90. end, true)
  91.  
  92. local removing = Players.PlayerRemoving:Connect(function(player)
  93.     if player == Target then
  94.         Target = nil
  95.         Hint.Text = "No one"
  96.         Hint.TextColor3 = Color3.new(0.7, 0.7, 0.7)
  97.         StarterGui:SetCore("SendNotification", {
  98.             Title = player.Name.." left";
  99.             Text = "Player has disconnected from the server.";
  100.             Duration = 10;
  101.         })
  102.     end
  103. end)
  104.  
  105. local changed; changed = Tool.AncestryChanged:Connect(function()
  106.     if not Tool:IsDescendantOf(game) then
  107.         Gui:Destroy()
  108.         chatted:Disconnect()
  109.         activated:Disconnect()
  110.         removing:Disconnect()
  111.         changed:Disconnect()
  112.     end
  113. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement