Need little bit of help with making "mute button" for "sound regions" read the text in this page, thank you

hello, it’s mari here, I have been very struggling with making mute button for sound regions since months ago, and I want to end the trouble and help many peoples by releasing sound region with mute button model. I’ll say the what I should say here below.

  1. I want to make “GUI button” that changes the “playing value” of the sound object that gets implemented inside every model of players in “workspace” upon clicking the GUI button,, I was kinda able to make GUI button changes it’s text by “Mute musics”(when musics isn’t muted) and “Unmute musics”(when musics are muted by GUI button)

  2. I do not know how to edit the script so it changes the “playing value” of sound object that is inside “local startercharacter script” that gets implemented in every player models. and it would be awesome to get helped so I can make free sound region with mute button asset in roblox model marketplace for everyone ;>}

  3. I tried to change the scripts with multiple ideas and changes, but never got luck at this.

also I might go show you guys about two codes I used for mute button and sound region script,

(mute button by robloxian on yt)

local mutebutton = script.Parent
local music = game.Players.LocalPlayer.Character:GetChildren("Sound")
playing = true

mutebutton.MouseButton1Click:Connect(function()
	if playing == true then
		music.Playing = false
		mutebutton.Text = "Unmute Musics"
		playing = false
	else
		music.Playing = true
		mutebutton.Text = "Mute Musics"
		playing = true
	end
end)
(sound region script by howtoroblox)

local sound = Instance.new("Sound", script)
sound.Looped = true


local char = script.Parent
local hrp = char:WaitForChild("HumanoidRootPart")


local areasGroup = workspace:WaitForChild("Areas")

local currentArea = nil


game:GetService("RunService").Heartbeat:Connect(function()


	local raycast = Ray.new(hrp.Position, hrp.CFrame.UpVector * -1000)

	local part = workspace:FindPartOnRayWithWhitelist(raycast, {areasGroup})


	if part and part.Parent == areasGroup then

		if part ~= currentArea then

			currentArea = part

			sound.SoundId = currentArea.Music.SoundId
			sound:Play()
		end 

	else

		currentArea = nil
		sound:Stop()
	end
end)

also I used some roblox studio tutorials on youtube for see how to make mute button and sound regions, but there was no video about how peoples can make mute button that mutes sound region musics despite some popular games like “bee swarm simulator” and “find the markers” have that functions.

howtoroblox’s guide of how to make sound regions which I used:
howtoroblox’s sound region video

robloxian’s guide of how to make mute buttons which I used and edited a bit:
robloxian’s mute button video

also the video of mute button functions in my game, I did something bit right but I’m not there yet.

need more informations for help me out? then please comment below to speak out, mari thank you.

1 Like

Generated by ChatGPT:

To make a mute button for sound regions, you can modify the script to reference the sound object inside the starter character script for each player. Here’s an example of how you can modify the mute button script:

local mutebutton = script.Parent
local playing = true

mutebutton.MouseButton1Click:Connect(function()
	local music = game.Players.LocalPlayer.Character:FindFirstChildOfClass("Sound")
	if music then
		if playing then
			music.Playing = false
			mutebutton.Text = "Unmute Musics"
			playing = false
		else
			music.Playing = true
			mutebutton.Text = "Mute Musics"
			playing = true
		end
	end
end)

Here, we use the FindFirstChildOfClass method to locate the sound object inside the player’s starter character script. If it is found, we modify the Playing property of the sound object to mute or unmute it. You can also add this script to a GUI button object in the game to make it functional.

Note that this script only works for the local player’s sound object. If you want to mute sound regions for all players, you’ll need to use a RemoteEvent to communicate between the client and server to modify the sound objects for each player.

Note that this solution may not work; it is just a suggestion for you to fix the code. I did not test those codes or methods before posting this. Feel free to reply to this thread and ask for more help if needed.

2 Likes

hello there, thanks for kinda helping me out with editing and fixing the script, now the “Sound” is found with FindFirstChildOfClass method, (I couldn’t do that before your suggestions) but now mute button doesn’t change it’s text on clicking,
in fact the mute button is not functioning at all, before putting your amazing script, it did changed text upon clicking the GUI button, but not for now since I put the new script, and also I think the script should find the Sound object inside player models inside “workspace” and make script able to modify the “playing property”.

…that’s just an my idea of how script can go, but I only have plans but no skills at making scripts, so it would be more awesome if you could help the script improve, thanks

also here is the video of using your suggested script on my game, however the gui button isn’t functioning yet.

thank you as always.

You should use SoundGroups to group all the Sounds under the SoundGroup to make it easier for you to Handle them.

That’s if I read your Topic correctly.

I’m sorry to say about this but, I barely even understand lua scripting, there is many functions I don’t even know about and I do have idea of how it could work it this way but I don’t know how to make it into real script. and it will take times to rewrite the entire soundregion in my game for use SoundGroups thing,
thanks for the help I guess, funky looking black cat creature who programs in lego game.