Edit: I have found out a way myself. No further replies needed. And thank you for helping.
I’m trying to make a script that mutes the Running sound found in the HumanoidRootPart, but I just can’t seem to figure out how I can toggle with the volume.
What do you want to achieve? I want to mute the “Running” sound when the player moves.
What is the issue? I don’t know how to mute it.
What solutions have you tried so far? I tried searching across posts on this site, and the Roblox Developer Hub, but I couldn’t understand well how I can perform what I want to achieve.
I’d just like to know how I can toggle with the volume with the Running sound. Any help is appreciated.
Fork RbxCharacterSound from StarterPlayerScripts in a Play Solo session, go into the script in Studio and set the volume of the walking sound in the data table to 0. If it does not support volume setting, add that support in.
The character sound script does some heavy lifting involving initialising the sound system (learned that you need to jump a lot of hoops before actually acting on the character to avoid memory leaks and all that), which involves the creation of sounds. You’ll thus want to intercept that and apply your own changes as desired.
--// Make sure it's a LocalScript inside StarterCharacterScripts //--
local MutedSounds = {
"Running",
"" -- Put in this table the name of the sounds you want muted
-- Case sensitive!
}
local LastVolume = {} -- Here will be stored the previous volumes
local hrp = script.Parent:WaitForChild("HumanoidRootPart")
local muted = false
local function ToggleMuted()
if muted == false then
muted = true
for i,v in pairs(MutedSounds) do
if v and v ~= "" then
spawn(function()
local sound = hrp:WaitForChild(v)
LastVolume[v] = sound.Volume -- Remember it
sound.Volume = 0
end)
end
end
else
muted = false
for i,v in pairs(MutedSounds) do
if v and v ~= "" then
spawn(function()
local last = LastVolume[v] or 1
local sound = hrp:WaitForChild(v)
sound.Volume = last
end)
end
end
end
end
--// To toggle the muted sounds, call ToggleMuted() ! //--
This code won’t work the way you think it will. The sound system is initialised per player per spawning character via a script in StarterPlayerScripts. This would set the volume of your own walking sounds to 0 volume but others will still be able to hear them.
An extra script just to mute sounds is unnecessary work where you can just modify the sound script itself not to play any sound during the running state.
Like colbert described, setting the volume to 0 will make it silent on the client, but others will still be able to hear it. Destroying it would be the better option in this scenario, as the sounds are client sided.
Destroying falls under the same circumstance of a client-side-only change not properly geared with the current sound script, except now you’re introducing the potential for failure into the script. Destroying is not a better option: changing the actual sound script not to play the movement sound is.
if you want to mute all the default character sounds entirely, just instance an empty localscript in StarterPlayerScripts or StarterCharacterScripts(can’t remember which it is anymore)
called RBXCharacterSounds. This will override roblox’s.
Since I’m probably wrong about what the name of the script is or where it’s located, hop into a game and check your player/character scripts
It really depends on how you do it, because the new sound system actually allows you to destroy and not play sound. It does indeed work, you just have to know how to pull it off. The sounds are actually not shown on the server because it is client-sided.
If the sound script has a built-in check for the existence of the sound before playing it, then that’s fine, but that’s still not really an appropriate workaround and you should just modify the sound script itself so you don’t have to rely on weird workarounds from the getgo. Forking the script and changing the behaviour is more ideal over unnecessarily adding processes to your game to accomplish this. Use the resources you’re already given.
If destroying sounds “works” in terms of stopping a sound for everyone else as opposed to just the client, this is an artifact of improper replication strategies on the character which has been a bug for some time. Destructions aren’t meant to replicate.
On the Official Roblox Create Documentation there is a part where it says: "*The StarterCharacterScripts class stores scripts to be parented in a player’s Player.Character, when they spawn. Unlike scripts stored in the PlayerScripts folder, these scripts will not persist when the player respawns.
If a script named Animate, Sound or Health is placed in this folder, they will replace the default scripts that are added to each Player.Character that is created*" So I hope that helped.