Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why isn't this audio script choosing the songs?

Asked by 9 years ago

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

Log in to vote
0
Answered by
woodengop 1134 Moderation Voter
9 years ago

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

0
Add the Quotation Marks. woodengop 1134 — 9y
Ad
Log in to vote
0
Answered by
Sublimus 992 Moderation Voter
9 years ago

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

Answer this question