This script is placed inside a model in workspace called MusicHolder along with some audios. Why does it work well in studio and choose random and different songs in studio, but in-game it chooses to play the same song over and over. The script :
print('ran')
local musicholder = script.Parent
local songList = {
musicholder:WaitForChild('CW'),
musicholder:WaitForChild('DeckDubstep'),
musicholder:WaitForChild('EhDe'),
musicholder:WaitForChild('JayKode'),
musicholder:WaitForChild('Ookay'),
musicholder:WaitForChild('SantaComes'),
musicholder:WaitForChild('XmasToMe'),
--musicholder:WaitForChild('Song'),
--musicholder:WaitForChild('Song'),
--musicholder:WaitForChild('Song')
-- we wait for each song
-- add the rest of the songs to this list
}
local songCount = #songList -- this returns the number of items in the table above so we only change as little code as possible when adding songs
while true do
wait(3)
local songNum = math.random(1, songCount) -- gets a random number in the range of the number of songs
print(songNum)
songList[songNum]:Play() -- we access the sound in the table and play it
songList[songNum].Ended:Wait() -- we wait until the song has finished then play anther song
end

1 comment
ok thx