kll91

ChatSpy

Dec 5th, 2024
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.13 KB | None | 0 0
  1. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  2. local StarterGui = game:GetService("StarterGui")
  3. local Players = game:GetService("Players")
  4. local LocalPlayer = Players.LocalPlayer
  5.  
  6. if(_G.CSConnections)then
  7.     for _, con in next,_G.CSConnections do
  8.         con:Disconnect()
  9.     end
  10. end
  11.  
  12. local function sysMsg(Text: string)
  13.     local Message  = {
  14.         Color = Color3.fromRGB(0,255,255);
  15.         Font = Enum.Font.SourceSansBold;
  16.         TextSize = 18;
  17.     }
  18.     Message.Text = Text
  19.     StarterGui:SetCore("ChatMakeSystemMessage",Message)
  20. end
  21.  
  22. local Chat = LocalPlayer.PlayerGui.Chat.Frame.ChatChannelParentFrame.Frame_MessageLogDisplay.Scroller :: Frame
  23. local OnMessageDoneFiltering = ReplicatedStorage:WaitForChild("DefaultChatSystemChatEvents"):WaitForChild("OnMessageDoneFiltering")
  24.  
  25.  
  26. _G.CSConnections = {}
  27. local PlayersLastMessage = {}
  28. local PlayersLastTarget = {}
  29.  
  30. _G.CSConnections['chat'] = Chat.ChildAdded:Connect(function(child)
  31.     if #child.TextLabel:GetChildren() >= 2 then return end
  32.     if not child.TextLabel:FindFirstChild("TextButton") then return end
  33.  
  34.     local yield
  35.     yield = child.TextLabel.Changed:Connect(function(p)
  36.         if p == "Text" then
  37.            yield:Disconnect() yield = nil
  38.         end
  39.     end) table.insert(_G.CSConnections, C)
  40.  
  41.     repeat task.wait()
  42.     until not yield
  43.  
  44.     local Text = child.TextLabel.Text:match('<font.-</font>(.*)')  :: TextLabel
  45.     local Name = child.TextLabel.TextButton.Text:match("%[(.*)%]") :: TextButton
  46.     PlayersLastMessage[Name] = Text
  47. end)
  48.  
  49. local function OnChatted(message, isMuted, speakerDisplay)
  50.     local isWhisper, Target, privMessage = message:match('(/w%s(.-)%s%s?(.*))')
  51.     message = privMessage or message
  52.     local notInChat = (message ~= PlayersLastMessage[speakerDisplay])
  53.     local isPrivate = (isWhisper or notInChat)
  54.     if not isPrivate then return end
  55.     if Target then
  56.         Target = Players[Target].DisplayName
  57.     end
  58.     local lastTarget = PlayersLastTarget[speakerDisplay]
  59.     sysMsg("["..speakerDisplay.." -> "..(Target or lastTarget or '?').."]: "..message)
  60.     PlayersLastTarget[speakerDisplay] = Target or lastTarget
  61. end
  62.  
  63. local blockedIds = StarterGui:GetCore("GetBlockedUserIds")
  64. local function isBlocked(player: Player)
  65.     for _, blockedId in pairs(blockedIds) do
  66.         if player.UserId == blockedId then
  67.             return true
  68.         end
  69.     end
  70.     return false
  71. end
  72.  
  73. local SpyEnabled = true
  74.  
  75. _G.CSConnections['self_logger'] = OnMessageDoneFiltering.OnClientEvent:Connect(function(packet, channel)
  76.     if packet.Message:match("/spy") then
  77.         SpyEnabled = not SpyEnabled
  78.         sysMsg("[[ Spy::"..(SpyEnabled and "ON" or "OFF").." ]]")
  79. end end)
  80.  
  81. sysMsg("[ Spying Chats ]")
  82. for _, Player: Player in next, Players:GetPlayers() do
  83.     if Player.Name == LocalPlayer.Name or isBlocked(Player) then continue end
  84.     local Connection = Player.Chatted:Connect(function(a,b)
  85.         if not SpyEnabled then return end
  86.         task.wait(.05) -- To wait for the ChildAdded to process the message
  87.         OnChatted(a,b, Player.DisplayName)
  88.     end)
  89.     table.insert(_G.CSConnections, Connection)
  90. end
Advertisement
Add Comment
Please, Sign In to add comment