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: All Instances are not pulled from a folder when assigned to

Previous Thread :: Next Thread 
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:03 PM
I am having some issues with this script I made. It's supposed to take sounds out of a folder and sort them into another folder in a random order, then playing the songs in the order used in the new folder. Then the songs reset and get sent to the old folder and it happens all over again.

However, the script refuses to put ALL the audio into the folder, it just picks out about half of the audio and moves it into the new folder. Here is the code:

http://pastebin.com/r6GYNXCP

Is there any possible way to fix this? I need help soon. Thanks!



Logic is best
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:09 PM
Bump



Logic is best
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:14 PM
Bump[2]



Logic is best
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:19 PM
Bump[3]



Logic is best
Report Abuse
EchoReaper is online. EchoReaper
Joined: 14 Oct 2008
Total Posts: 4323
19 Jun 2015 10:21 PM
You don't need to bump your thread until it's off the first page. I'm not going to help you because of your unnecessary bumping.
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
19 Jun 2015 10:24 PM
local Song = Songs[math.random(1,#Songs)]

Looks to me like you are getting a random song, not setting it as random.
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:25 PM
@echo
Well, there was no point in announcing that if you were not going to even help.



Logic is best
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:26 PM
@Geo
I may have worded it wrong
I am pulling a random audio and parenting it to the new folder
so it will be randomized when it gets in the folder



Logic is best
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
19 Jun 2015 10:32 PM
Yeah then what I said is true. You are pulling out a random song, therefore; you might pull out the same song. Also, it'd be much more efficient if you made this one function.
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:35 PM
@Geo
if it continues to pull out a random song, how can it pull out the same song if it is no longer parented to that folder? It was sent to another folder so it shouldn't be chosen (I could be wrong)



Logic is best
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
19 Jun 2015 10:37 PM
oh yeah i c now u r correct mai bad

But then lets say it removes the 3rd one from the list. What do you think this loop will do when it finishes the second?
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:50 PM
@Geo
I tried to wrap my head around that and I don't think I know e.o
It might error... or it would move on to the next song.

also, I did some things to make it work better in my favor, however it seems to leave about 4 songs in the Stash

Modified code:
http://pastebin.com/TDqKuQ9S

around where it says:

local Songs = SongStash:GetChildren()
local Number = #Songs
for a = 1,Number do

(lines 32-34)

It just kinda acts like there isn't 21 Instances in the folder, when there are a total of 21 Instances in the folder... Maybe it hasn't loaded all the songs yet and decides to run? I do not know



Logic is best
Report Abuse
FOXmcloud021 is not online. FOXmcloud021
Joined: 14 Apr 2012
Total Posts: 3512
19 Jun 2015 10:54 PM
Here is the result of the modified script, now it doesnt seem to help (what I did) at all :(

/6r6gFPS.png?1

(im.gur)



Logic is best
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
19 Jun 2015 10:55 PM
print is a useful method for debugging
Report Abuse
GeoVolcano is not online. GeoVolcano
Joined: 05 Jul 2012
Total Posts: 1433
19 Jun 2015 11:01 PM
Don't you think you should redefine the length since you removed 1...?
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
19 Jun 2015 11:06 PM
I don't know what is most annoying about you so far:

1. Your unnecessary bumping
2. Your unnecessary commenting
3. Your unnecessary semicolons

--

However, I will help you out, if you do not annoy me any further.
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
19 Jun 2015 11:25 PM
Logic error #1:

function LoadSongs()
print("Shuffling Songs")
local Songs = SongStash:GetChildren() --returns a table of the current songs
local Number = #Songs
for a = 1, Number do
local Song = Songs[math.random(1,#Songs)] --that table does not change length
Song.Parent = SongCache --not here even
end
PlaySongs()
end

You get a table of the current songs whenever you call GetChildren. Re-parenting a child does not remove it from the table. You can do this manually, as so:

function LoadSongs()
print("Shuffling Songs")
local Songs = SongStash:GetChildren()
for a = 1, #Songs do
local index = math.random(#Songs) --save random index as variable
local Song = Songs[index] --use it to pick a song
Song.Parent = SongCache --re-parent the song to cache
table.remove(Songs, index) --remove song from table
end
PlaySongs()
end
Report Abuse
ShungTzu is not online. ShungTzu
Joined: 14 Jun 2014
Total Posts: 959
19 Jun 2015 11:31 PM
Now you can get rid of that second folder.
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