Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --###----------[[DEVELOPER NOTES]]----------###--
- --[[
- WRITTEN BY: FEAHREN.
- DESCRIPTION: ENABLES THE ATTACHED SOUND-INSTANCE TO ITERATE—ADDITIONALLY AT RANDOM—THROUGH A GIVEN LIST OF SONGS.
- ]]
- --###----------[[VARIABLES]]----------###--
- local SongIdList = {
- --
- }
- local SelectRandom = true --// Scrambles the SongList Array with a Fisher-Yate Shuffle.
- local MusicObject = --// Object path - preferably the script's parent.
- --###----------[[FUNCTIONS]]----------###--
- local function GetRandomSet(SongIdList)
- for Iteration = #SongIdList, 1, -1 do
- --------------
- local RandomIndex = Random.new(tick()):NextInteger(1, Iteration)
- --------------
- SongIdList[Iteration] = SongIdList[RandomIndex]
- SongIdList[RandomIndex] = SongIdList[Iteration]
- end
- ---------------
- return SongIdList
- end
- local function InitializeSongInteration()
- local Set = (SelectRandom and GetRandomSet(SongIdList) or SongIdList)
- --------------
- for _,SongId in pairs(Set) do
- --------------
- MusicObject.SoundId = "https://www.roblox.com/asset/?id="..SongId
- --------------
- if not (MusicObject.IsLoaded) then
- MusicObject.Loaded:Wait()
- end
- --------------
- MusicObject:Play()
- MusicObject.Ended:Wait()
- --------------
- MusicObject:Stop()
- end
- end
- --###----------[[INITIALIZATION]]----------###--
- InitializeSongIteration()
Advertisement
Add Comment
Please, Sign In to add comment