Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --##########################################
- --THIS SCRIPT IS MEANT PUBLIC, PLEASE CREDIT ME
- --##########################################
- local badAudios = {"6829105824", "2221"} -- 2221 is for debugging
- local markTime = 10 -- how long people are highlighted for, set to "forever" to never unhighlight the player
- local function highlightPlayer(inst)
- if not inst or not inst.Parent then return end -- check if the instance still exists
- local highlight = inst.Parent:FindFirstChildOfClass("Highlight")
- if not highlight then
- highlight = Instance.new("Highlight")
- highlight.Name = "crasher"
- highlight.Parent = inst.Parent
- highlight.FillColor3 = Color3.fromRGB(255, 0, 0)
- highlight.FillTransparency = 0.3
- else
- highlight.FillColor3 = Color3.fromRGB(255, 0, 0)
- highlight.FillTransparency = 0.3
- end
- if markTime ~= "forever" then
- task.spawn(function()
- wait(markTime)
- if highlight and highlight.Parent then
- highlight:Destroy()
- end
- end)
- end
- end
- local function checkAudio(inst)
- if not inst or not inst.Parent then return end -- check if the instance still exists
- for i, item in ipairs(badAudios) do
- if string.match(inst.SoundId, item) then
- inst.SoundId = "0"
- highlightPlayer(inst)
- print("CRASH AUDIO!")
- break
- end
- end
- end
- for i, player in ipairs(game:GetService("Players"):GetPlayers()) do
- if player.Backpack then
- for _, tool in ipairs(player.Backpack:GetChildren()) do
- if tool:IsA("Tool") and tool.Handle and tool.Handle:IsA("Sound") then
- checkAudio(tool.Handle)
- end
- end
- end
- end
- game:GetService("Workspace").DescendantAdded:Connect(function(new)
- if new:IsA("Sound") and new.Parent:IsA("Tool") then
- if string.len(new.SoundId) > 2 then
- print("------------")
- print("Parent: "..new.Parent.Parent.Name)
- print(new.SoundId)
- checkAudio(new)
- print("-------------")
- end
- end
- end)
Advertisement
Comments
-
Comment was deleted
-
- I rewrite from the original script:
- https://pastebin.com/rzrpp61R
- Youtube original script: https://youtu.be/AefZCK-Pv6g
- Improved/Updated version:
- Used Color3.fromRGB instead of Color3.new to specify the color of the highlight with RGB values.
- Refactored the code to make it more readable and maintainable.
- Used wait function instead of task.wait for better performance.
- Added local variables to limit the scope of variables and improve performance.
- Used string.match instead of string.find for a more precise match of the audio file IDs.
- Overall, the improvements should make the script more efficient, readable, and robust.
Add Comment
Please, Sign In to add comment
Advertisement