Alright so one way you can achieve this is by having an array of different sounds,
So now that we have a table of all the sound effects that you want to play choosing a random one is very simple, you can just use the math.random function in order to get a random index.
1 | local SoundIndex = math.random( 1 , 3 ) |
Obviously you'd change it from 1,3 to whatever your minimum/maximum is depending on how many sound effects you have, and then after you have gotten your random index you can just create a sound object the normal way you usually do, but this time for the SoundID you'd want to use the table and reference the index from math.random so it'd look something like this
1 | local Sound = Instance.new( "Sound" ) |
2 | Sound.Parent = game.Workspace.part |
3 | Sound.SoundId = Sounds [ SoundIndex ] |
So once you have all that done, the script should look something like this (Please don't just copy the script, try to read what I said before as it will be more beneficial to you in the long run.)
07 | local SoundIndex = math.random( 1 , 3 ) |
09 | local Sound = Instance.new( "Sound" ) |
10 | Sound.Parent = game.Workspace.part |
11 | Sound.SoundId = Sounds [ SoundIndex ] |