Is this possible?

Hi DevForum, for my game menu, is it possible to have music randomly selected to play? I have 5 songs that I would like to put into my game menu, anytime, somebody joins one of those 5 songs will play randomly.

I am just asking if it is possible, I am not asking if someone can do it for me. I am pretty sure that is against the rules.

1 Like

Yes it’s possible to do, and quite simple. Create an array with the SoundIDs you want to be played, and select randomly from that table:

local Player = game:GetService("Players").LocalPlayer
local MusicIDs = {

local Sound ="Sound")
Sound.Parent = Player
Sound.Looped = true -- Delete if you don't want the music to loop
Sound.SoundId = "rbxassetid://".. MusicIDs[math.random(1, #MusicIDs)]

I hope this helps!


Sorry, it doesn’t seem to be working…

If I type in the id’s of the sound it doesn’t work.
Am I supposed to put it in a certain spot?

Have you put this inside a LocalScript somewhere on the client? (StarterPlayer or some other folder similar)

Yes, I will try again though. Just in case I put it in the wrong spot.

You can give the music numbers and use math.random() between 1 and 5.


I just realized a capitalization mistake on my part, change Sound.SoundID to Sound.SoundId

( I have also changed my original post )

1 Like

Oh my goodness, you are amazing! Thank you so much!!! :grin: :grin: :grin:

1 Like