hi! i want to make a muffled/underwater effect whenever the player goes to the core roblox menu.
i wrote this script myself that scans through all sound objects then add and tween the EQ.
however, my game constantly creates new sound meanwhile (eg. footsteps) and that would not be registered afterwards.
how do i make it such that it constantly checks for new sounds and add in the descendants?
any help would be appreciated! thanks
-- muffled sound active
guiservice.MenuOpened:Connect(function()
for _, v in pairs(game:GetDescendants()) do
if v:IsA("Sound") then
local eq = Instance.new("EqualizerSoundEffect")
eq.Parent = v
eq.Name = "EQ"
if eq then
local tween = ts:Create(eq, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {HighGain = -80, MidGain = -40, LowGain = 1})
tween:Play()
end
end
end
end)
-- muffled sound gone
guiservice.MenuClosed:Connect(function()
for _, v in pairs(game:GetDescendants()) do
if v:IsA("Sound") then
local eq = v:FindFirstChild("EQ")
if eq then
local tween = ts:Create(eq, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {HighGain = 1, MidGain = 1, LowGain = 1})
tween:Play()
tween.Completed:Connect(function()
eq:Destroy()
end)
end
end
end
end)
It should be registering, try printing out v after it has checked it. Also another thing to note is that it doesn’t check to see if the sound already has an equalizer effect, so it makes duplicate sounds every time you open and close the menu, try this:
-- muffled sound active
guiservice.MenuOpened:Connect(function()
for _, v in pairs(game:GetDescendants()) do
if v:IsA("Sound") and not v:FindFirstChild("EqualizerSoundEffect") then
print(v.Name)
local eq = Instance.new("EqualizerSoundEffect")
eq.Parent = v
eq.Name = "EQ"
if eq then
local tween = ts:Create(eq, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {HighGain = -80, MidGain = -40, LowGain = 1})
tween:Play()
end
end
end
end)
Theres a chance that it may not be receiving it at all, since the loop is called every time the menu is activated
Could be that the equalizers are overlapping to make it seem stronger, you can try adjusting the values in the original equalizer once it has been made once.