Playback volume stuck at 0?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I want a sound to play multiple times without issues.

  1. What is the issue? Include screenshots / videos if possible!

When I play a sound then stop it using sound:Stop() then play it again the playback volume is always 0 even though playing is true and time position is moving normally. (I have looked at playback volume through client and server).

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
  • Changing the sound
  • Moving the sound to workspace
  • Adding prints to verify code is running properly (it is)

Here is the module script that is responsible for the sound platying at it works fine:

local SoundModule = {}

SoundModule.Muted = false
SoundModule.BeforeVolume = 1
SoundModule.PlayingSound = workspace.Music.Surface.Surface
SoundModule.CurrentZone = ""

function StopMusic()
	for i, v :Sound in pairs(game.Workspace.Music:GetDescendants()) do
		if v:IsA("Sound") then
			v:Stop()
		end
	end
end

function SoundModule:Play(Zone :string)
	print("Playing new sound for zone: "..Zone)
	StopMusic()
	local Sounds = workspace.Music:FindFirstChild(Zone):GetChildren()
	
	if #Sounds <= 0 then
		warn("No sounds found for zone: "..Zone)
		return
	end
	
	if SoundModule.PlayingSound ~= nil then
		SoundModule.PlayingSound:Stop()
	end
	
	local RandomNumber = math.random(1, #Sounds)
	local SoundToPlay = nil
	
	for i, v in pairs(Sounds) do
		if i == RandomNumber then
			SoundToPlay = v
			break
		end
	end
	
	if SoundToPlay == nil then
		warn("Counlnt find sound, Random index: "..RandomNumber)
		return
	end
	
	SoundModule.PlayingSound = SoundToPlay
	SoundModule.PlayingSound:Play()
	
	if SoundModule.Muted then
		SoundModule:Mute()
	end
	
	print("Sound Playing: "..SoundModule.PlayingSound.Name.." with ID: "..SoundModule.PlayingSound.SoundId)
end

function SoundModule:Mute()
	SoundModule.Muted = true
	SoundModule.BeforeVolume = SoundModule.PlayingSound.Volume
	SoundModule.PlayingSound.Volume = 0
	print("Muting sound")
end

function SoundModule:UnMute()
	SoundModule.Muted = false
	SoundModule.PlayingSound.Volume = SoundModule.BeforeVolume
	print("Unmuting sound")
end



SoundModule.PlayingSound.Ended:Connect(function()
	print("Sound ended!")
	SoundModule:Play(SoundModule.CurrentZone)
end)

return SoundModule

When I play the game and go into a zone then out then back in the sound for that zone plays but the playback volume is always 0. Here is the output:

16:50:06.609  Playing new sound for zone: Surface  -  Client - SoundModule:17
16:50:06.610  Sound Playing: Town Talk with ID: rbxassetid://1845756489  -  Client - SoundModule:52
16:50:11.942  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:11.942  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52
16:50:11.942  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:11.943  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52
16:50:15.375  Playing new sound for zone: Surface  -  Client - SoundModule:17
16:50:15.376  Sound Playing: Uptown with ID: rbxassetid://1845554017  -  Client - SoundModule:52
16:50:15.376  Playing new sound for zone: Surface  -  Client - SoundModule:17
16:50:15.376  Sound Playing: Uptown with ID: rbxassetid://1845554017  -  Client - SoundModule:52
16:50:17.125  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:17.126  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52
16:50:17.126  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:17.126  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52
16:50:19.176  Playing new sound for zone: Surface  -  Client - SoundModule:17
16:50:19.176  Sound Playing: Fight Together with ID: rbxassetid://1843324336  -  Client - SoundModule:52
16:50:19.176  Playing new sound for zone: Surface  -  Client - SoundModule:17
16:50:19.176  Sound Playing: Fight Together with ID: rbxassetid://1843324336  -  Client - SoundModule:52
16:50:20.675  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:20.675  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52
16:50:20.676  Playing new sound for zone: Lightness  -  Client - SoundModule:17
16:50:20.676  Sound Playing: Lightness with ID: rbxassetid://1841435715  -  Client - SoundModule:52

Sond plays fine the first time but doesnt any other time. I might just be making some stupid mistake.

Did you mean

if SoundModule.Muted then
	SoundModule:Unmute()
end

?

Yeah I was gonna say the same thing.

I changed it but it didnt fix the issue, also I would want to keep it like that becaue if the music is muted and then a new song plays it shouldnt unmute (all the music volume is not 0 by default).

Is it possible that somehow the beforeVolume variable gets switched to a zero?

Dont know, Ive recorded the script and it works now. Although I dont think so as when testing the volume was normal (0.5) but the playback volume was 0.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.