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.