Advertisement
DrawingJhon

Ping

Nov 27th, 2021
1,367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.16 KB | None | 0 0
  1. local players = game:GetService("Players")
  2. local function getPlayers(text)
  3.     print(text)
  4.     if not text then return {} end
  5.     if text == "everyone" or text == "here" then
  6.         return players:GetPlayers()
  7.     else
  8.         local tab = {}
  9.         for i, v in pairs(players:GetPlayers()) do
  10.             if v.Name:lower():sub(1, #text) == text:lower() and text ~= "" then
  11.                 table.insert(tab, v)
  12.             end
  13.         end
  14.         return tab
  15.     end
  16. end
  17.  
  18. local function chatted(msg)
  19.     for i = 1, #msg do
  20.         local prev = msg:sub(i - 1, i - 1)
  21.         if msg:sub(i, i) == "@" and (prev == "" or string.match(prev, "%s")) then
  22.             for _, plyr in pairs(getPlayers(string.match(msg:sub(i + 1), "^%S*"))) do
  23.                 if plyr then
  24.                     local pgui = plyr:findFirstChildOfClass("PlayerGui")
  25.                     if pgui then
  26.                         local sound = Instance.new("Sound", pgui)
  27.                         sound.Name = "Ping_RBX"
  28.                         sound.Volume = 1
  29.                         sound.SoundId = "rbxassetid://570433034"
  30.                         sound:Play()
  31.                         sound.Ended:Connect(function() sound:Destroy() end)
  32.                     end
  33.                 end
  34.             end
  35.         end
  36.     end
  37. end
  38.  
  39. for i, v in pairs(players:GetChildren()) do
  40.     v.Chatted:Connect(chatted)
  41. end
  42.  
  43. players.PlayerAdded:Connect(function(p)
  44.     p.Chatted:Connect(chatted)
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement