CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 09:57 AM |
This script works, in ROBLOX Studio, but not in the ROBLOX Player.
--------------------------------------
local c = script:GetChildren() --(Music is grouped inside the script as Sounds)
while true do local i = c[math.random(#c)] --Get all Sounds in Parent then randomize # of children wait(5) i:Play() wait(i.TimeLength) --Wait the "TimeLength" of the Sound i:Stop() end
--------------------------------------
The script is written to play a series of randomized music, one after an other; When each song has reached its TimeLength, the song stops then 5 seconds later, a new song is played.
For some reason, this only works in RS. In the ROBLOX Player, it does not even play the music. |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 06 Aug 2015 09:58 AM |
| Where is the script located, and what type of script is it? |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 10:01 AM |
| The script is just a regular "Script" in the Workspace. |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 10:07 AM |
I heard that the "TimeLength" property in LUA is broken. Maybe, this is something ROBLOX needs to fix, before this script could work?
This script seem fine to me, though. |
|
|
| Report Abuse |
|
|
DinoSal
|
  |
| Joined: 24 Oct 2013 |
| Total Posts: 1117 |
|
|
| 06 Aug 2015 10:16 AM |
make it a local script
~Clickest |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 06 Aug 2015 10:17 AM |
| @Dino, I'm not sure how that'd work. He wants to play music to the server, and local scripts only run in players... |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 10:24 AM |
| I will test out the local script idea and work my way around that. |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 10:32 AM |
This is the code I updated, to try a LocalScript instead:
---------------------------------------------------------
local c = game.Workspace.LocalScript:GetChildren()
while true do local i = c[math.random(#c)] wait(5) i:Play() wait(i.TimeLength) i:Stop() end
---------------------------------------------------------
I am not familiar with the differences between Scripts and LocalScripts. I tried this code, in a LocalScript though. Did not work at all. |
|
|
| Report Abuse |
|
|
Xulp
|
  |
| Joined: 24 Apr 2012 |
| Total Posts: 451 |
|
|
| 06 Aug 2015 10:32 AM |
| TimeLength isn't broken, it's documented not to work server side I believe. I think it has to be run locally in order for that property to work. |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 10:35 AM |
Probably why it works in Studio but not properly in the ROBLOX Player.
I will try to re-create the script, maybe using the TimeLength property or a different way. |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2015 11:13 AM |
| make a script and put a localscript in it. The script should be in the workspace, and script it so it will take the localscript in it and copy it into every player. That should work. :D |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 12:45 PM |
| I will try that, thank you! |
|
|
| Report Abuse |
|
|
CopyJ
|
  |
| Joined: 31 Aug 2010 |
| Total Posts: 1390 |
|
|
| 06 Aug 2015 01:35 PM |
Just realized that I can just have the game give a localscript to players automatically, anyway.
But thank you. |
|
|
| Report Abuse |
|
|