How to make a radio that blocks loud sounds

Today I will be showing you a tutorial of how to make a radio that also blocks loud sounds.

For today’s “loud sound” sample, I will be using [ Content Deleted ] - Roblox listen at your own risk

For today’s “not loud sound” example, I will be using https://www.roblox.com/library/5558240798/Get-Stick-Bugged-FULL listen at no risk at all

So let’s start!

First, I’m not a very good builder, so I’ll be using a mesh radio from the gasp! Toolbox. Let’s name it “RadioPart.”

Now let’s make a tool, so our users can put in an audio ID. Put the mesh inside the tool, and name the tool “Radio”. Now put a part on the back of the radio and name it “Handle”. Weld the radio and handle together. Rotate the handle until the speaker faces outward.

It should be something like this.

Now we need to make the GUI to allow users to input an ID. First, put a new ScreenGUI in StarterGUI. Then add a TextBox. Adjust the Position to where you would like it, and make the Size {0.2, 0},{0.05, 0}. Set TextScaled to True.

Now, add a TextLabel above that that says something like, “Input an Audio ID to play here.”

So now that we have the GUI, we need to script the TextBox. Create a RemoteEvent in ReplicatedStorage. Open a new LocalScript under the TextBox and put this code in:

script.Parent.FocusLost:Connect(function(enterPressed)
	if enterPressed then
                game.ReplicatedStorage.RemoteEvent:FireServer(script.Parent.Text)
	end
end)

This tells the server, “Hey! I have an audio here and I need to play it!”

Now put this Script in ServerScriptService:

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(p, id)
	print(id)
    for i, v in ipairs(p.Character:GetChildren()) do
		if v:IsA("Sound") then
			v:Destroy()
		end
	end
	local s = Instance.new("Sound", p.Character)
	s.SoundId = "rbxassetid://" .. id
        s.Looped = true
	s:Play()
end)

Then, put this script in a LocalScript under game.StarterPlayer.StarterPlayerScripts:

game.DescendantAdded:Connect(function(v)
	if v:IsA("Sound") then
		repeat wait() until v.PlaybackLoudness > 0
		if v.PlaybackLoudness >= 800 then
			v:Destroy()
		end
	end
end)

Want to see it tested? Take off your headphones, and watch this (Walk Em Down audio):

And here’s the Stick Bugged Audio:

Now there’s only a small thing we need to do: make it so the GUI only pops up when the tool is equipped.

First, move the ScreenGUI into the tool. Next, name the ScreenGUI “RadioGui”. Next, create this LocalScript and parent it under the tool as well:

script.Parent.Equipped:Connect(function()
	script.Parent.RadioGui:Clone().Parent = game.Players.LocalPlayer.PlayerGui
end)

script.Parent.Unequipped:Connect(function()
	game.Players.LocalPlayer.PlayerGui.RadioGui:Destroy()
	game.ReplicatedStorage.RemoteEvent2:FireServer(game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Sound"))
end)

And that should be all! Please tell me, did you find this helpful? (Votes are anonymous)

  • Yes
  • No

0 voters

EDIT: https://www.roblox.com/library/639750143/Marshmello-Alone was blocked, so you may want to set the audio threshold higher, such as 600. Walk Em Down registers 740 which is really loud, so I wouldn’t go above 650 or so.

EDIT 2: Walk Em Down has an average of 875, Alone is hitting above 700 and isn’t that loud. It’s up to you to set it, but I think mine will default at around 800.

EDIT 3: Added a feature where if you put a new ID in, it destroys the old song.

17 Likes

Nice tutorial! Though the sounds does give quite a scare at the beginning before being paused!

Thank you! Unfortunately this does happen, but it generally cuts out pretty fast.

Pretty good tutorial! However your remote is vulnerable to exploiters by giving the client full server-side control over deleting sounds without proper protection.

Alright, I’ll research some methods to make it more secure.

Instead of actually telling the server to destroy the sound, destroy the sound locally, you can’t affect the other clients + an exploiter wouldn’t benefit of not destroying the sound.

It’s actually more than just sounds, you can even fire the remote to destroy players, character and everything since the server destroys the given object.

That’s a good idea that I thought of, but I was worried it would cause lag on the server from thousands of sounds playing (possibly).

That’s why you reuse the same sound, no reason to make a new one

That doesn’t really work for games that are multiplayer unless

for i, v in ipairs(game.Players:GetChildren()) do
    local s = Instance.new("Sound", v.Character)
end

You can store the sound for the player then reuse the sound

That’s kind of what I was trying to say, but maybe a PlayerAdded would work better.

My idea is when you make a new sound see in a table if there is a sound for a player and if not then assign a key as the player then the value as the sound, otherwise, if there’s a sound then reuse it if it’s not destroyed

1 Like

As harsh as it sounds, this is an extremely poor method of doing this. The level of lag this will cause (not even mentioning the remote event being spammed) will be very high.

You are indexing through every instance in the entire game (most games that will be well over 10,000) every 0.1 seconds just to find a sound that is over a playback loudness. This will not only be affecting radios, but every single sound instance in the game. An exploiter could crash a game that has this pretty easily.

I suggest you switch this to a remote event that fires to the client to monitor it. And instead of it going above 800 once, it should have to above 800 multiple times. Otherwise this is a very inefficient way of solving loud audios.

1 Like

Alright, I’ll check out some other methods.

1 Like

But why use a remote event if that’s not really needed? You can do all the detection on clientside with descendantadded and a single check for every descendant.

1 Like

@maumaumaumaumaumua and @RVVZ

I updated the main post, tell me if this solution works.

And yes I still have the while loop, but that’s not of main importance for me right now

You haven’t changed anything, and the loop IS the problem.

Sorry but anyone whos reading this I can’t suggest you use this tutorial unless you want a broken game.

1 Like

Here’s the problem yet again, relying on the client, just do it on the clientside, you can just remote:FireServer(obj,800) and boom, not kicked.

Look at the server script where it fires RemoteEvent2

Tell me how a while true do loop breaks a game. It may not be the most memory-efficient, sure, but unless you have a potato, it’s not gonna break your game.

I didn’t even notice that. I guess I’ll work on this a bit more.

2 Likes