Disabling all sounds for one player on death

Hello, I’m creating pretty realistic FPS game. I already created blackscreen on death which slowly fades when you’re respawned, but I wanna on death all sounds which played near dead player disabling immediately, (but only for him). I already have one possible solution, with teleporting camera somewhere out map. But I feel this is not best way. Maybe there better ones?

You could set all sounds to a soundgroup, and use a local script to decrease the soundgroup volume when the local player dies.

local Player = game:GetService("Players").LocalPlayer

if Player:FindFirstChild("FakeSOUNDS") then
	for _,v in Player.FAKESOUNDS:GetChildren() do
		for _,d in workspace:GetDescendants() do
			if d:IsA("Sound") then
				d.Volume = v:FindFirstChild(d.Name).Value
				--game:GetService("TweenService"):Create(d, TweenInfo.new(2), {Volume = v:FindFirstChild(d.Name).Value}):Play()
			end
		end
	end
	Player:FindFirstChild("FakeSOUNDS"):Destroy()
end
Player.Character:FindFirstChildOfClass("Humanoid").Died:Connect(function()
	local FakeSOUNDS = Instance.new("Folder")
	FakeSOUNDS.Name = "FakeSOUNDS"
	FakeSOUNDS.Parent = Player
	for _,v in workspace:GetDescendants() do
		if v:IsA("Sound") then
			local sound = Instance.new("NumberValue")
			sound.Name = v.Name
			sound.Value = v.Volume
			sound.Parent = FakeSOUNDS
            v.Volume = 0
		--	game:GetService("TweenService"):Create(v, TweenInfo.new(2), {Volume = 0}):Play()
		end
	end
end)

Like this? Make sure its in startercharacter so the script runs again when player respawns. resetting the entire workspace sounds volume. for realism you can tween the sounds volume to 0 if you wanna!

Yes, because almost all my gun sounds playing in player HRP, but will it work with character default sounds (jumping, dying, walking sound)?

1 Like

Yes it’ll disable every single sound in workspace.