Advertisement
TheRealAaron

Audio anti crash 2.0

May 4th, 2023 (edited)
142
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.17 KB | None | 0 0
  1. --##########################################
  2. --THIS SCRIPT IS MEANT PUBLIC, PLEASE CREDIT ME
  3. --##########################################
  4.  
  5. local badAudios = {"6829105824", "2221"} -- 2221 is for debugging
  6. local markTime = 10 -- how long people are highlighted for, set to "forever" to never unhighlight the player
  7.  
  8. local function highlightPlayer(inst)
  9.     if not inst or not inst.Parent then return end -- check if the instance still exists
  10.    
  11.     local highlight = inst.Parent:FindFirstChildOfClass("Highlight")
  12.     if not highlight then
  13.         highlight = Instance.new("Highlight")
  14.         highlight.Name = "crasher"
  15.         highlight.Parent = inst.Parent
  16.         highlight.FillColor3 = Color3.fromRGB(255, 0, 0)
  17.         highlight.FillTransparency = 0.3
  18.     else
  19.         highlight.FillColor3 = Color3.fromRGB(255, 0, 0)
  20.         highlight.FillTransparency = 0.3
  21.     end
  22.    
  23.     if markTime ~= "forever" then
  24.         task.spawn(function()
  25.             wait(markTime)
  26.             if highlight and highlight.Parent then
  27.                 highlight:Destroy()
  28.             end
  29.         end)
  30.     end
  31. end
  32.  
  33. local function checkAudio(inst)
  34.     if not inst or not inst.Parent then return end -- check if the instance still exists
  35.    
  36.     for i, item in ipairs(badAudios) do
  37.         if string.match(inst.SoundId, item) then
  38.             inst.SoundId = "0"
  39.             highlightPlayer(inst)
  40.             print("CRASH AUDIO!")
  41.             break
  42.         end
  43.     end
  44. end
  45.  
  46. for i, player in ipairs(game:GetService("Players"):GetPlayers()) do
  47.     if player.Backpack then
  48.         for _, tool in ipairs(player.Backpack:GetChildren()) do
  49.             if tool:IsA("Tool") and tool.Handle and tool.Handle:IsA("Sound") then
  50.                 checkAudio(tool.Handle)
  51.             end
  52.         end
  53.     end
  54. end
  55.  
  56. game:GetService("Workspace").DescendantAdded:Connect(function(new)
  57.     if new:IsA("Sound") and new.Parent:IsA("Tool") then
  58.         if string.len(new.SoundId) > 2 then
  59.             print("------------")
  60.             print("Parent: "..new.Parent.Parent.Name)
  61.             print(new.SoundId)
  62.             checkAudio(new)
  63.             print("-------------")
  64.         end
  65.     end
  66. end)
  67.  
Advertisement
Comments
  • TheRealAaron
    2 years
    Comment was deleted
  • TheRealAaron
    2 years
    # text 0.65 KB | 0 0
    1. I rewrite from the original script:
    2. https://pastebin.com/rzrpp61R
    3. Youtube original script: https://youtu.be/AefZCK-Pv6g
    4.  
    5.  
    6. Improved/Updated version:
    7.  
    8.  
    9. Used Color3.fromRGB instead of Color3.new to specify the color of the highlight with RGB values.
    10.  
    11. Refactored the code to make it more readable and maintainable.
    12.  
    13. Used wait function instead of task.wait for better performance.
    14.  
    15. Added local variables to limit the scope of variables and improve performance.
    16.  
    17. Used string.match instead of string.find for a more precise match of the audio file IDs.
    18.  
    19.  
    20.  
    21. Overall, the improvements should make the script more efficient, readable, and robust.
Add Comment
Please, Sign In to add comment
Advertisement