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 » Scripting Helpers
Home Search
 

Re: Whats wrong with my music script? I find no flaws.

Previous Thread :: Next Thread 
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:19 PM
I put it in a music script and found out it played with around 4 songs in it but once I started adding and testing it became glitchy. Now I enter and it just plays ONE random song and stops completely. I need it to go through the whole list then loop again through the list.


local songIds = {
["164269189"] = 120,
["144652618"] = 75,
["153859524"] = 60,
["143550410"] = 115,
["148409311"] = 120,
["148409206"] = 120,
["162942693"] = 120,
["164996701"] = 110,
["148334572"] = 120,
["148512213"] = 120,
["159559354"] = 120,
["159561632"] = 120,
["167962120"] = 80,
["158363043"] = 88,
["144249596"] = 112
}

for songId, _ in pairs (songIds) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. songId)
end

script.Parent:Stop()

while true do
for songId, songLength in pairs (songIds) do
script.Parent:Stop()
script.Parent.SoundId = "http://www.roblox.com/asset/?id=" .. songId
script.Parent:Play()
wait(songLength)
end
end

-Upcoming Developer-
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:22 PM
1

-Upcoming Developer-
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:23 PM
2

-Upcoming Developer-
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:24 PM
This is my script lol

Change this
for songId, songLength in pairs (songIds) do


to this

for songId, songLength in ipairs (songIds) do
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:28 PM
and remove the quotes around the IDs
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:31 PM
Actually never mind
I have no idea why its not playing in order, but for me its not breaking
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:33 PM
128 I will test it again go to my place only one song plays it stops. I am doing thumbs up and I will put you in a description as a developer and you can join the studio group I am creating. If it doesnt work will you rewrite it. it may have a max # of songs it can support.

-Upcoming Developer-
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:36 PM
What order would you play it in? There is no way Lua can figure that out.
Do this

local songIds = {
{"164269189", 120},
{"144652618", 75},
{"153859524", 60},
{"143550410", 115},
{"148409311", 120},
{"148409206", 120},
{"162942693", 120},
{"164996701", 110},
{"148334572", 120},
{"148512213", 120},
{"159559354", 120},
{"159561632", 120},
{"167962120", 80},
{"158363043", 88},
{"144249596", 112}
}

for songId, _ in ipairs (songIds) do
Game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. _[1])
end

script.Parent:Stop()

while true do
for songId, songLength in ipairs (songIds) do
script.Parent:Stop()
script.Parent.SoundId = "http://www.roblox.com/asset/?id=" .. songLength[1]
script.Parent:Play()
wait(songLength[2])
end
end
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:37 PM
@Cnt
Using ipairs makes it crash
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:37 PM
Honestly I don't care which order it plays, I will only start caring when lua plays the same song repeatedly which would be very rare.

-Upcoming Developer-
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:39 PM
Cntkillme fixed it, but I don't get why when I tried to use ipairs it crashed, its because the for loop didn't run, but why?
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:40 PM
All of you get credits and can join thanks means alot.

-Upcoming Developer-
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:41 PM
How is that possible O_o?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:43 PM
Oh, when you used it, It just not iterate through the table at all so it was doing while true do end
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:44 PM
How many songs will this support?

-Upcoming Developer-
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:45 PM
As much as you want
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:45 PM
@Cnt
It was more of a question of why is it doing that
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:46 PM
ipairs only iterates numerical keys.

while true do
for songId, songLength in ipairs (songIds) do --no numerical keys = no loop
script.Parent:Stop()
script.Parent.SoundId = "http://www.roblox.com/asset/?id=" .. songLength[1]
script.Parent:Play()
wait(songLength[2])
end
--no loop = no wait
end
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
25 Jul 2014 11:47 PM
But why?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jul 2014 11:48 PM
Why what?
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
25 Jul 2014 11:49 PM
in game its froze plays one and is frozen. join game

-Upcoming Developer-
Report Abuse
128GB is not online. 128GB
Joined: 17 Apr 2014
Total Posts: 8056
26 Jul 2014 12:03 AM
Script currently being fixed and model updated, sorry, the new one will be tested online before I update it, sorry for the trouble
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
26 Jul 2014 12:05 AM
Ok its ok for the trouble lol it means alot you guys are helping me. Just message me the model link. MEANS ALOT!!!!!!!!!!!!!!

-Upcoming Developer-
Report Abuse
Eternalfireeater is not online. Eternalfireeater
Joined: 01 May 2011
Total Posts: 10027
26 Jul 2014 12:25 AM
Is it in a LocalScript?
Preloading only works in LocalScripts
Report Abuse
Declassification is not online. Declassification
Joined: 08 Oct 2008
Total Posts: 8621
26 Jul 2014 12:29 AM
AHAHAHAHAHHAHHHAHAHA I BET IT ISNT LOL THANKS

-Upcoming Developer-
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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