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: Music Player - Works in Studio but not ROBLOX Player

Previous Thread :: Next Thread 
CopyJ is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. DinoSal
Joined: 24 Oct 2013
Total Posts: 1117
06 Aug 2015 10:16 AM

make it a local script

~Clickest
Report Abuse
Darkenus is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
veryawesomeboy is not online. veryawesomeboy
Joined: 21 May 2013
Total Posts: 479
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 is not online. CopyJ
Joined: 31 Aug 2010
Total Posts: 1390
06 Aug 2015 12:45 PM
I will try that, thank you!
Report Abuse
CopyJ is not online. 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
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