Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this local script muting the sounds?

Asked by 2 years ago

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.

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. chillyenorman80 2 — 2y

1 answer

Log in to vote
0
Answered by
lamgogo 56
2 years ago

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)
Ad

Answer this question