The original script is here:
local music = {
"1839526588",
"1837871067",
"4648169560"
}
local music1 = script.Parent.Music
local muted = false
while true do
for i = 1, #music do
music1.SoundId = "rbxassetid://"..music[i]
wait(3)
music1:Play()
wait(music1.TimeLength)
end
end
I have tried to implement math.random into this by doing this:
local music = {
"1839526588",
"1837871067",
"4648169560"
}
local randomMusic = math.random(#music - #music + 1,#music)
local music1 = script.Parent.Music
local muted = false
local ConvertRandomMusicToMusicId = tostring(randomMusic)
local chosenMusic = ConvertRandomMusicToMusicId
while true do
print(chosenMusic)
for i = 1, #music do
music1.SoundId = "rbxassetid://"..chosenMusic[i]
wait(3)
music1:Play()
wait(music1.TimeLength)
end
end
But it does not seem to work.
Can someone please explain this?

1 comment
Thanks!