Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this local script muting the sounds?

I have a sound regions music style, and I'm trying to use a mute button in the bottom right of the screen to mute the music if you want to.

local hubmusic = game.StarterGui.SoundRegions.hubmusic
local off = false

script.Parent.MouseButton1Click:Connect(function()
	print("music function connected")

	if off == false then
		off = true

		hubmusic.Volume = ("0")
		print(hubmusic.Volume)
	elseif off == true then
		off = false
		hubmusic.Volume = ("0.5")
print(hubmusic.Volume)
	end
end)

What's weird is that it successfully changes the volume of the music because it tell it to print its value, but in the game, the volume was not changed at all.

1 comment

0

I believe it is because you're attempting to set the music's volume to a string and not a number? Instead of ("0"), just put 0.

1 answer

the volume,u are making it as a string,instead change it to a number this is the script in case u dont understand what am i saying:

local hubmusic = game.StarterGui.SoundRegions.hubmusic
local off = false

script.Parent.MouseButton1Click:Connect(function()
    print("music function connected")

    if off == false then
        off = true

        hubmusic.Volume = 0
        print(hubmusic.Volume)
    elseif off == true then
        off = false
        hubmusic.Volume = 0.5
print(hubmusic.Volume)
    end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.