RPD777
|
  |
| Joined: 31 May 2016 |
| Total Posts: 121 |
|
|
| 25 Jul 2017 02:51 AM |
I have made this script which should select a random song from the table and play the song.There is obviously something wrong with the script because it is not working.
Any help would be greatly appreciated.
----------------------------------------- local TableOfIDs = {"123456789","236563786","987654321","823336098","697260266"} math.randomseed(tick())
script.Parent.MouseButton1Click:connect(function() while wait() do script.Parent.Music:Stop() script.Parent.Music.SoundId = "rbxassetid://"..(TableOfIDs{math.random(1,#TableOfIDs)}) script.Parent.Music:Play() wait(20) end end)
|
|
|
| Report Abuse |
|
|
RPD777
|
  |
| Joined: 31 May 2016 |
| Total Posts: 121 |
|
|
| 25 Jul 2017 02:52 AM |
| Btw the songs are just random numbers I put in. |
|
|
| Report Abuse |
|
|
|
| 25 Jul 2017 03:16 AM |
the problem would be in this line:
script.Parent.Music.SoundId = "rbxassetid://"..(TableOfIDs{math.random(1,#TableOfIDs)})
you are using {} to get an item in a table, you need to use [] to do that. to fix it you can do:
script.Parent.Music.SoundId = "rbxassetid://"..(TableOfIDs[math.random(1,#TableOfIDs)]) |
|
|
| Report Abuse |
|
|
RPD777
|
  |
| Joined: 31 May 2016 |
| Total Posts: 121 |
|
|
| 25 Jul 2017 04:10 AM |
| Thank you so much Navycarrier!, it now works perfectly. I can't thank you enough ;) |
|
|
| Report Abuse |
|
|