Rain sound on/off button

Hey Developers,

I’m using Rain Plugin (Rain plugin) in my experience, but the sound is too loud even when i put the sound on the minimum volume.

So i came up with an idea, the idea is that i will add on/off rain volume button.
But the problem is i have no idea what to do… I could make on/off music button easily, but I’m not that familiar with plugins…

Could anyone help me please?

Some info:
Rain sound asset id: 1516791621
Rain editor:

I would be really happy for any help or advice!

Thanks in advance
-jeziskrista

The sound is stored in the sound service, inside of a sound group.
You can access it here.

local sound = game.SoundService:WaitForChild("__RainSoundGroup"):WaitForChild("RainSound")
1 Like

uhh, i kinda don’t understand what to do…

The sound isn’t there yet, because it hasn’t been created by the rain plugin yet, You’ll have to do it through a script.

Put this script inside of a button.

local button = script.Parent
local sound = game.SoundService:WaitForChild("__RainSoundGroup"):WaitForChild("RainSound")

local originSoundVolume = sound.Volume
local Switch = true -- /// Debounce

button.Activated:Connect(function()
	if Switch then
		
		Switch = not Switch -- Turns the debounce on or off depending on what it is
		sound.Volume = 0 -- Turns the volume off
		
	elseif not Switch then
		
		Switch = not Switch -- Same here
		sound.Volume = originSoundVolume -- Turns the volume back on, you can change this with a number if you want.
		
	end
end)
1 Like

This helped really helped me! Thank you so much!

Just a question, could you add a line to the script which will change the text of the button? Like “Rain sound on” and “Rain sound off”

I just don’t want to mess up something in the script

1 Like

Sure.

local button = script.Parent
local sound = game.SoundService:WaitForChild("__RainSoundGroup"):WaitForChild("RainSound")

local originSoundVolume = sound.Volume
local Switch = true -- /// Debounce

button.Activated:Connect(function()
	if Switch then

		Switch = not Switch -- Turns the debounce on or off depending on what it is
		button.Text = "Rain Sound: Off" -- Change this to make the text whatever you want it to be
		sound.Volume = 0 -- Turns the volume off

	elseif not Switch then

		Switch = not Switch -- Same here
		button.Text = "Rain Sound: On" -- Change this to make the text whatever you want it to be
		sound.Volume = originSoundVolume -- Turns the volume back on, you can change this with a number if you want.

	end
end)
1 Like

Thank you so much man! This helped so much! I’m so thankful

1 Like