Audio not Muffling when player presses Escape

yeah!

replace

toggleEqualizer()

to

task.spawn(toggleEqualizer)

I’m now starting to believe that it is a roblox problem, the task.spawn isn’t working either

probably

To check if the menu is opened or closed, just use .MenuOpened and .MenuClosed, no need for hacky solutions.

Code:

-- LocalScript
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
local currentMusic = nil

-- Function to find and update the current music
local function updateCurrentMusic()
	currentMusic = workspace:FindFirstChild("GameMusic")
end

-- Function to toggle the equalizer effect
local function toggleEqualizer()
	if currentMusic then
		local equalizer = currentMusic:FindFirstChild("GameMusicEqualizer")
		if equalizer then
			equalizer.Enabled = not equalizer.Enabled
			print("Equalizer toggled: " .. tostring(equalizer.Enabled))  -- Debugging print
		else
			updateCurrentMusic()  -- Update the reference and try again
			if currentMusic then
				local equalizer = currentMusic:FindFirstChild("GameMusicEqualizer")
				if equalizer then
					equalizer.Enabled = not equalizer.Enabled
					print("Equalizer toggled after update: " .. tostring(equalizer.Enabled))  -- Debugging print
				end
			end
		end
	else
		updateCurrentMusic()  -- Update the reference if no music is currently playing
	end
end

-- Event handler for menu actions
GuiService.MenuOpened:Connect(toggleEqualizer)
GuiService.MenuClosed:Connect(toggleEqualizer)

-- Initial update of the current music reference
updateCurrentMusic()
3 Likes

Thank you so much! This really helps a lot!

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