Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this audio script choosing the songs?

I have an audio, it works when i put the ID in directly, but i dont want that here is my script

script.Parent:Play()

songs = {35930009,143763384}
print("nothing wrong with #'s")
repeat
script.Parent.SoundId = ("http://www.roblox.com/asset/?id=" .. math.random(1,#songs))
print("song chosen")
	wait(10)
until 9 + 10 == 21

please help THANKS

2 answers

This part: math.random(1,#songs) is generating a number between 1 and the length of songs, but not actually accessing that index of the songs list.

script.Parent:Play()

songs = {35930009,143763384}
print("nothing wrong with #'s")
repeat
script.Parent.SoundId = ("http://www.roblox.com/asset/?id="..songs[math.random(1,#songs)]) --Should fix it
print("song chosen")
    wait(10)
until 9 + 10 == 21

I see a mistake already

script.Parent:Play()

songs = {"35930009","143763384"}
print("nothing wrong with #'s")
repeat
script.Parent.SoundId = ("http://www.roblox.com/asset/?id=" .. math.random(1,#songs))
print("song chosen")
    wait(10)
until 9 + 10 == 21

1 comment

0

Add the Quotation Marks.

This discussion is preserved as it was. New answers, comments, and votes are closed.