Open in the app to sign in, vote and reply

Help · Open

Stuck with TopBar Plus

· · 3 votes · 4 comments · from Discord

I got the model and everything set. I want to do a "Mute Music" and "Unmute Music" button that turns on and off the playing music in-game. I have the button and music but the button is not working. Can someone help? I would also want to add a few more buttons.

Comments

Team ·

Hey! You said it isn't working so I assume you already have the code for this.
Could you send it over here so we could examine it? 👀
Thanks!

· · in reply to Mavreis

Hi! Is it possible to do this via Discord or on this platform?

· · in reply to Mavreis

By the way I have this script in StarterPlayerScripts:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")

local Icon = require(ReplicatedStorage.TopbarPlus.Icon)

local MusicGroup = SoundService:WaitForChild("Music")

local originalVolume = MusicGroup.Volume

local MusicIcon = Icon.new()
:setName("MusicToggle")
:setLabel("Mute Music")
:setLeft()

local isMuted = false

MusicIcon:bindEvent("selected", function()
isMuted = true
MusicGroup.Volume = 0
MusicIcon:setLabel("Unmute Music")
print("Music muted")
end)

MusicIcon:bindEvent("deselected", function()
isMuted = false
MusicGroup.Volume = originalVolume
MusicIcon:setLabel("Mute Music")
print("Music unmuted")
end)

-

And a script in SoundService:
local Music = game:GetService("SoundService"):WaitForChild("Sound")
Music:Play()

· · in reply to Roblox player

Hope this works