i making guess the anime game and i have music system. my mute button act weird when i change the volume of the sound the mute button doesnt work. i dont know why please help me.
mute script(local script):
local RP = game:GetService("ReplicatedStorage")
local music = RP:WaitForChild("CurrentMusic")
script.Parent.MouseButton1Click:Connect(function()
if music.Volume == 0.5 then
music.Volume = 0
else
music.Volume = 0.5
end
end)
I couldn’t hear anything in the video you attached, but I think the issue is that the music keeps playing when you set the volume to 0. If you want the music to pause, you can use the Sound:Pause() function to pause the music.
When you change the values in the if statement. You Ignore the fact volume is set to 0.5 by your music system If your going to change the values within the if statement. You need to set the values so that your if statements’ conditions can be true.
I think that sounds don’t update as soon as the value is changed, they change when they play again, for example, if you change the volume, the music has to play again/restart/pause then unpause to change
local RP = game:GetService("ReplicatedStorage")
local music = RP:WaitForChild("CurrentMusic")
local isMuted = false
script.Parent.MouseButton1Click:Connect(function()
isMuted = not isMuted
if isMuted then
music.Volume = 0
else
music.Volume = 0.5
end
end)