Music Toggle Button with Volume Restore thumbnail
0 views0 copies0 likes

Music Toggle Button with Volume Restore

Universal script

Copy it, then test it in your own Studio place.

UI systems Verified

Script code

10 lines · 0.3 KB
Download
local music = game:GetService("SoundService"):WaitForChild("LobbyMusic")local button = script.Parentlocal volume = music.Volumelocal muted = volume == 0local function update()	music.Volume = muted and 0 or volume	button.Text = muted and "Music: off" or "Music: on"endbutton.Activated:Connect(function() muted = not muted; update() end)update()

About this script

Place a Sound named LobbyMusic in SoundService and add this LocalScript inside a TextButton. The button mutes the music for the current player without restarting the track and restores its starting volume when unmuted. Use it for a soundtrack preference separate from effects. Set the sound to loop if appropriate and test switching several times while the music is playing.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local music = game:GetService("SoundService"):WaitForChild("LobbyMusic")
local button = script.Parent
local volume = music.Volume
local muted = volume == 0
local function update()
	music.Volume = muted and 0 or volume
	button.Text = muted and "Music: off" or "Music: on"
end
button.Activated:Connect(function() muted = not muted; update() end)
update()