I have a multiplayer zombie game project. As soon as zombies/humans win, a music plays. It's either winning(human) or losing(zombie) music.
How do I make random music play when one of the actions happen?
Assign each music track a number then generate a random number and when the number is selected use that number to play the track assigned said number
random number generator taken from roblox wiki
for _ = 1,1 do print(math.random(10)) wait(1) end
EXAMPLE SCRIPT
local 1 = track1 local 2 = track2 local 3 = track3 local track = (math.random(3)) -- put number of tracks where 3 is
it would need some work to get it to work :D but it is the basic idea
local musicids={123456,123456,1234556} --Change these to the music ids you want to play, feel free to add some music function PickRandomFrom(tab) return tab[math.random(1,#tab)] end local id=PickRandomFrom(musicids) local music=Instance.new("Sound",game.Workspace) music.SoundId=id --I'm not sure if it's called SoundId, probably something else music:Play()