How to fix viewportframe duplicating sounds?

Working on a combat game, and wanted to have a viewport frame next to your health and stamina that shows your character, and after some troubleshooting I got it working well. The viewportframe essentially duplicates the player and centers the camera in front of your torso creating a nice character viewport, but there is still one problem left.

It keeps duplicating any sound emitting from the player or anything parented to it, (tool sounds, death sounds etc) its very distracting as it completely messes up the phase of weapon sounds and makes them very loud and distorted (some sounds even get delayed and play over creating a slap back delay effect) and I’m just wondering if its possible to remove all sounds in the cloned character for the viewportframe?

I previously tried looping through all the descendants and children of the duplicated character with an in pairs loop but I couldn’t get it to work, I’m looking to destroy all sounds inside the duplicated character to prevent this from happening. Which one would I need? Descendants? Children? Or something else?

Instead of destroying the sounds, try setting their volume to 0. I’ve had a similar problem and that fixed it. Hope this helps!

Children means only the children of whatever instance you are trying to get them from. Descendants also means the children of the children of the children and so on. So, if you would loop through the character try this:

for i, v in pairs(character:GetDescendants()) do
 if v:IsA("Sound") then
  --mute or destroy, whatever you prefer
 end
end
1 Like

Don’t forget, sounds don’t just play from “Sound” instances, they can also be played from a variety of instances, as seen in the following screenshot:

image

Thank you for your solution and sorry for the late reply, I will try this!!