|
| 13 Jun 2015 11:11 AM |
The following script is supposed to add support for different music in different areas in a certain world, yet when run in play solo, it constantly fires for reasons I do not know, giving the error, "Maximum re-entrancy exceeded"
Any help on why would be appreciated.
function Music() twopart = false if (script.Music2.SoundId ~= "http://www.roblox.com/asset/?id=0") then twopart = true else twopart = false end play = true while (play == true) do if (twopart == true) then script.Music1.Looped = false script.Music1:Play() Wait(script.Music1.TimeLength) script.Music2:Play() Wait(script.Music2.TimeLength) elseif (twopart == false) then script.Music1.Looped = true script.Music1:Play() end end end
script.Music1.Changed:connect(Music) Music() |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 11:13 AM |
| If Music1 is playing, then it it being changed constantly. The timelength is the changing property of it. |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 11:15 AM |
I thought TimePosition was the changing property?
choo choo |
|
|
| Report Abuse |
|
|
| |
|
|
| 13 Jun 2015 11:25 AM |
So... Any clues on why this doesn't work?
choo choo |
|
|
| Report Abuse |
|
|
97neko
|
  |
| Joined: 14 Sep 2014 |
| Total Posts: 16159 |
|
|
| 13 Jun 2015 11:35 AM |
have you ever heard of a table...
mr developer man |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 11:36 AM |
How would a table help me here...?
choo choo |
|
|
| Report Abuse |
|
|
97neko
|
  |
| Joined: 14 Sep 2014 |
| Total Posts: 16159 |
|
|
| 13 Jun 2015 11:41 AM |
local m = script:GetChildren() for i,v in ipairs(m) do if v:IsA('Sound') then v:Play() wait(v.TimeLength) end end
mr developer man |
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 13 Jun 2015 11:41 AM |
| BlueWizard just told you why it doesn't work. Changed fires whenever any property is changed. When you play a song, it changes IsPaused and IsPlaying once, and TimePosition for the rest of the duration of the audio. |
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 13 Jun 2015 11:42 AM |
| Oh, and you are changing Looped, which causes Changed to fire *another* time. |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 11:42 AM |
@Jode Oh lol. I didn't quite get that from his explanation.
choo choo |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 11:43 AM |
So how should I go about remedying this?
choo choo |
|
|
| Report Abuse |
|
|
jode6543
|
  |
| Joined: 16 Jun 2009 |
| Total Posts: 5363 |
|
|
| 13 Jun 2015 11:46 AM |
| Changed passes a string indicating the name of the property that was changed. I assume you only care about one property changing in particular; just check if the string matches the name of that property before executing the code. |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 12:01 PM |
Got it working, thanks guys!
choo choo |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 12:37 PM |
After a bit testing to see if everything works, I found that studio will crash if I go into an area that plays a one-part track, then into an area that plays a different one-part track, and I do not know why.
choo choo |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 12:40 PM |
@OP
I've been looking for such a script myself for a week now.
I always explain the idea of different music player in different areas but I can never find a solution. Mind posting the finished working script? |
|
|
| Report Abuse |
|
|
|
| 13 Jun 2015 01:08 PM |
Uh... Sure? Still has quite a few bugs to be worked out but ok.
http://www.roblox.com/Area-Tracks-item?id=258433121
choo choo |
|
|
| Report Abuse |
|
|
|
| 21 Jun 2017 06:02 PM |
hey can you help me with a script that plays songs in different areas and i have one script that does that but the problem is that it only works n solo mode and not in online mode plz help me
|
|
|
| Report Abuse |
|
|