✓ Accepted answer
I assume what you have are sounds inside of a part that are named "2", "3", "4", etc. First you have to find the number in the array, this can be done by picked a random number(1 - 16) and then searching for the number that is in that spot
For Instance, if I do math.random(1, 16) and a three appears, '4' is the picked number because it is the third variable in the array
Here is my finished script:
Sounds = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17"}
function Music()
local notes = math.random(5, 10)
for i = 1, notes do
local num = math.random(1, 16)
local name = Sounds[num]
print(num, name)
if name and script.Parent:FindFirstChild(name) then
script.Parent:FindFirstChild(name):Play()
end
wait(.5)
end
end
wait(1)
Music()
If you notice, when run the 'print' at line 8 returns the number, then the variable that is in the place of the number in the table
Hope this helped you!