Hi - I’m working on a sound system for my game and I’ve ran into this pretty simple issue. How would I create a function that fades out an audio but over a specified time (say 2 seconds, for example)? All my sounds are all at different volumes too so that is what complicates it.
function fadeAudio(audio, fadeTime)
local before = audio.Volume
local timeVar = fadeTime * 1000
for i = 0, timeVar, 1 do
local y = before - (i / (timeVar / before))
audio.Volume = y
wait()
end
audio:Stop()
audio.Volume = before
end
I created this function and it fades it smoothly but not over the time specified with the fadeTime
variable.
Any help would be great!