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

Why does my gui text not change back to Mute?

I want to make a music gui that changes the mute bg music/unmute bg music button. For some reason, it changes from ("Mute") to ("Unmute") but not back to ("Mute") and this is my script.

Top Half


-- variables --
local sound = game.SoundService.CustomSound
local frame = script.Parent.Settings
local ID = script.Parent.Settings.MusicID

-- open button --
script.Parent.Open.Activated:Connect(function()
	frame.Visible = true
end)

-- open button --
script.Parent.Settings.Close.Activated:Connect(function()
	frame.Visible = false
end)

-- music ID --
sound.SoundID.Value = ID.Text
sound.SoundId = sound.SoundID.Value

Important Part


-- mute music --
script.Parent.Settings.Mute.Activated:Connect(function()
	game.SoundService.PlayingSounds.Volume = 0
	script.Parent.Settings.Mute.Text = ("Unmute")
end)

-- unmute music --
script.Parent.Settings.Mute.Activated:Connect(function()
	if script.Parent.Settings.Mute.Text ~= ("Mute") then
		script.Parent.Settings.Mute.Text = ("Mute")
		game.SoundService.PlayingSounds.Volume = 0.5
	end
end)


1 answer

✓ Accepted answer

You don't need to Connect to the same event twice, which I believe is your problem.

script.Parent.Settings.Mute.Activated:Connect(function()
    if script.Parent.Settings.Mute.Text ~= ("Mute") then
        script.Parent.Settings.Mute.Text = ("Mute")
        game.SoundService.PlayingSounds.Volume = 0.5
    else
        game.SoundService.PlayingSounds.Volume = 0
         script.Parent.Settings.Mute.Text = ("Unmute")
    end
end)

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