Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make audio fade in and out inside a loop, inside a loop?

I've tried using this script.

while true do
	wait()
	if game.Lighting.ClockTime >= 19 then
		for i = 0, 0.08, 0.01 do
			workspace.Hoot.Volume = i
			workspace.Crickets.Volume = i
			workspace.Birds.Volume = -i
			wait()
		end
		for i = 0, 0.1, 0.01 do
			workspace.Wind.Volume = -i
			wait()
		end
	elseif game.Lighting.ClockTime >= 6 then
		for i = 0, 0.08, 0.01 do
			workspace.Hoot.Volume = -i
			workspace.Crickets.Volume = -i
			workspace.Birds.Volume = i
			wait()
		end
		for i = 0, 0.1, 0.01 do
			workspace.Wind.Volume = i
			wait()
		end
	end
end

As you can see, the fade in and out part is a loop itself inside a loop. Using this method, the audio fades in and out every second. My intention is for the audio to fade once every time day or night comes. Is there a better method to dong to

1 comment

0

Maybe also mix the sounds..

1 answer

Maybe at the start of the script, It should make a "Sound" instance, and it should put the ID in. Then, at the time you set it at, the music fades. While that's happening, It should Change the ID. Then so on.

This discussion is preserved as it was. New answers, comments, and votes are closed.