I found this Module as a Free Model last month by the user of Bruce and I’ve been trying to figure it out, but it’s just been giving me some issues. The person left a LocalScript which requires the module and calls the StartUp()
function.
My issue:
- When the module finds a deleted sound it just loops another sound.
- When the module is done playing the sounds if it even works, then it just loops the last sound.
I don’t know this Module been giving my issues and I need to start searching for another free module since I’m not super experienced in making a complex module like this.
The Playlist Module:
return {{
SongArtist = "none1",
SongName = "deletd",
ID = 0 --redacted (is number, is actually a deleted sound)
}, {
SongArtist = "none2",
SongName = "error sfx",
ID = 0 --redacted (is number, not deleted sound)
}, {
SongArtist = "none3",
SongName = "correct sfx",
ID = 0 --redacted (is number, not deleted sound)
}, {
SongArtist = "none4",
SongName = "place sfx",
ID = 0 --redacted (is number, not deleted sound)
}}
Music Controller Module:
local MarketplaceService = game:GetService("MarketplaceService")
local function MusicRemover(Sound, ...)
local Table = {}
local Value = 0
while not Table[1] and Value < 3 do
Table = {pcall(Sound, ...)}
Value = Value + 1
end
return table.remove(Table, 1), unpack(Table)
end
local AudioDetails = {
Playlist = require(script.DefaultPlaylist),
TestAudio = Instance.new("Sound", workspace),
Audio = workspace:WaitForChild("Music"),
CurrentMusic = 0
}
local function CurrentMusicPlaying(Sound)
if Sound == nil then return false end
local ProductInfo = MusicRemover(MarketplaceService.GetProductInfo, MarketplaceService, Sound)
local SoundName = MarketplaceService:GetProductInfo(Sound)
if not ProductInfo then
return false
end
if SoundName then
if string.find(SoundName.Description, "removed") or string.find(SoundName.Description, "Removed") or string.find(SoundName.Name, "removed") or string.find(SoundName.Name, "Removed") then
return false
end
else
return false
end
if not MusicRemover(function()
AudioDetails.TestAudio:Stop()
AudioDetails.TestAudio.SoundId = "rbxassetid://"..tostring(Sound)
AudioDetails.TestAudio:Play()
end) then
return false
end
task.wait(2)
return AudioDetails.TestAudio.IsPlaying
end
local function AudioPlaylistDetails(Details)
local Table = {}
math.randomseed(os.time())
for _, Insert in ipairs(Details) do
table.insert(Table, math.random(1, #Table + 1), Insert)
end
return Table
end
local function AudioSetup()
local MusicDetails = nil
AudioDetails.Audio:Stop()
AudioDetails.Audio.TimePosition = 0
if not AudioDetails.Playlist[AudioDetails.CurrentMusic + 1] then
AudioDetails.Playlist = AudioPlaylistDetails(AudioDetails.Playlist)
AudioDetails.CurrentMusic = 0
AudioSetup()
return
end
MusicDetails = AudioDetails.Playlist[AudioDetails.CurrentMusic + 1]
if not CurrentMusicPlaying(AudioDetails.Playlist[AudioDetails.CurrentMusic + 1].ID) then
table.remove(AudioDetails.Playlist, AudioDetails.CurrentMusic + 1)
AudioSetup()
return
end
AudioDetails.CurrentMusic = AudioDetails.CurrentMusic + 1
AudioDetails.Audio:SetAttribute("SongName", MusicDetails.SongName)
AudioDetails.Audio:SetAttribute("SongArtist", MusicDetails.SongArtist)
AudioDetails.Audio.SoundId = "rbxassetid://" .. MusicDetails.ID
AudioDetails.Audio:Play()
return true
end
function AudioDetails.StartUp()
AudioDetails.TestAudio.Name = "TestMusic"
AudioDetails.TestAudio.Volume = 0
AudioDetails.Audio.Ended:Connect(function()
AudioSetup()
end)
AudioDetails.Playlist = AudioPlaylistDetails(AudioDetails.Playlist)
AudioSetup()
end
return AudioDetails
The Local Script:
require(game.ReplicatedStorage.MusicControllerModule).StartUp()