The localscript
local Currsound = script.Parent[v.Name] MusicModule.Fadeout(Currsound) Currsound:Stop() wait(1) script.Parent.Sea:Play()
The module
local MusicModule = {} function Fadeout(Currsound) for count = 1,5 do Currsound.Volume = Currsound.Volume - 0.1 end end return MusicModule
I wanted a module so i can fade music with just 1 line of code My error is Players.Sofian9600.PlayerGui.REGIONSMUSIC.RegionalMusic:26: attempt to call a nil value
Module script:
local MusicModule = {} MusicModule.Fadeout = function(sound) for count = 1,5 do sound.Volume = sound.Volume - 0.1 end end return MusicModule
Local script:
local Currsound = script.Parent[v.Name] local moduleScript = yourmodulescript -- Write there modulescript location moduleScript.Fadeout(Currsound) -- call the function inside the modulescript wait(1.6) -- wait for fadeout to finish Currsound:Stop() wait(1) script.Parent.Sea:Play()