Hello, I made GUI of where you click button and it plays songs. What I did was made a button GUI and added an empty Audio inside of it. Then inside the empty Audio, I added a script which is below. It works well but the only problem, I want to make it when you click, the list of songs in script don't go in order, they are shuffled. How do I do that?
while true do
script.Parent.SoundId= "rbxassetid://142304703" --1 Fortunate Son
script.Parent:Play()
wait(150)
script.Parent.SoundId= "rbxassetid://142304778" --2 I Can See Clearly Now
script.Parent:Play()
wait(128)
script.Parent.SoundId= "rbxassetid://142304968" --3 Imagine
script.Parent:Play()
wait(395)
script.Parent.SoundId= "rbxassetid://142305080" --4 Lets Groove
script.Parent:Play()
wait(183)
script.Parent.SoundId= "rbxassetid://142386715" --26 Can't Touch This
script.Parent:Play()
wait(167)
end
Also, the "wait()" is the amount of time that song plays. For example a song that is "wait(128) is 1:28 seconds long. Just so you know. But anyways how can I make them play in a shuffled order?

14 comments
It works but the only problem is when I enter a game, it starts playing the music even though I never clicked the GUI! I want to make it so you click the GUI, it starts playing. Not when you immediately enter a server.
Ok, I see. Just modify the script to how you want it
Actually, invite me to the team create so that I can help
btw, that's not a problem. you just need to have a function in the script for example, gui.TextButton.MouseButton1Click:Connect(function() --code here end)
What part of the script I can put this function?
well, i don't know where everything in your game is so i can't help you unless i'm in Team create
I don't know, I did put your name for invitation for team create but nothing happened.
you have to tell me what game it is and give me the link ,-,
I'm sorry for making things complicated for you. I was inactive from ROBLOX recently and haven't used studio in more than a year so that's why I have lack of knowledge of Team Create and etc. But for some reason now it doesn't play music while I join game. Hold on yet, I'll send you link when I need your help.
Your song script does make music but the only problem it just repeats one music, that's it. The music just goes looped without changing it to a different song. By the way, this is where I'm testing; https://www.roblox.com/games/175535220/School-setttt
By the way, there seems to be wrong with "local randomSong = musicTable[math.random(1, #musicTable)]" because it doesn't play random songs at all. It just keeps looping the first song that comes on.
Ok, so I got it to not looped because I changed from "[math.random(1, #musicTable)]" to "[math.random(0, #musicTable)]". I don't know about that, but now it doesn't replay one song for me.
Sometimes it still loops and remains in one song but other times I saw it switch to another song. Wierd. Must be ROBLOX glitch.
You are only supposed to call math.randomseed once on the server/client, not repeatedly. Due to a quirk in how its implemented, similar values will produce almost identical first random numbers (which is exactly what ShadowNinja is running into).