I’m still trying to wrap my ahead around Lua as I’m still new to this kind of stuff, but I just want to know a better method to fade out audios/effects than what I’m doing now (which is a mess)
sound = workspace:WaitForChild("night_sfx") -- looped audio track
sound.Volume = 0
while sound.Volume < 0.1 do -- fade in until 0.1
wait(0.1)
sound.Volume = (sound.Volume + 0.0005) -- add to volume
end
print("done")
script.Disabled = true -- this only works half the time
I’m just looking for a good way I can combine and make this script fade in/fade out the audio by a command from another script, and get better at making any sort of future versions as a beginner.
so you want another script to access the code of this script? if so I would check out ModuleScripts and tbh I still don’t fully understand your problem so please explain in more detail
you can use tweenservice to tween the sound’s volume, also you can localize your variables
local sound = workspace:WaitForChild("night_sfx") -- looped audio track
sound.Volume = 0
local tweenservice = game:GetService("TweenService") -- getting the tween service
local transitiontime = 1 -- the time it will take for the tween to complete
local tween = tweenservice:Create(sound, TweenInfo.new(transitiontime), {Volume = 1}) -- making the tween a variable for further use
tween:Play() -- playing the tween
tween.Completed:Wait() -- waiting for the tween to complete
print("done")
script.Disabled = true -- this only works half the time