generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Song randomizer

Previous Thread :: Next Thread 
RPD777 is not online. 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 is not online. 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
navycarrier is not online. navycarrier
Joined: 18 Feb 2014
Total Posts: 18
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image