Mute button not working after using :music command

  1. What do you want to achieve?
    I want to add a mute button in my game that can mute/unmute audio added by an admin command.
    (Example: Someone runs the command :music 1839627997, a player can then mute/unmute the audio)

  2. What is the issue?
    When I add a sound into Workspace without using the music command the mute feature works fine. But after using the :music ID command from Adonis Admin, the mute button stops working.

  3. What solutions have you tried so far?
    I’ve looked on the Dev Forum and also a whole bunch of YouTube tutorials, but nothing really talks about how Adonis Admin (or really any admin system in general) would affect a mute button script.

  4. After that, you should include more details if you have any.
    I noticed when using the music command, it creates a Sound in Workspace called “ADONIS_SOUND” when in-game. So in Studio, I named the sound to ADONIS_SOUND thinking that maybe it would recognize it as the same object after using the music command. But that didn’t work.

Method 1 with the Sound added to Workspace:

Method 2 without the Sound added to Workspace:

The LocalScript inside of the TextButton:

local music = game.Workspace.ADONIS_SOUND

script.Parent.MouseButton1Click:Connect(function()

	if music.Volume == 0 then
		music.Volume = 1
	else
		music.Volume = 0
	end
end)
1 Like

I would default to just using “workspace” to reference it. but it looks as if the instance is being added after removed or just added, and it’s referenced before it even exists. Try Referencing it in the connection.

script.Parent.MouseButton1Click:Connect(function()
    local music = workspace:WaitForChild("ADONIS_SOUND")
	if music.Volume == 0 then
		music.Volume = 1
	else
		music.Volume = 0
	end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.