sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 01:21 PM |
Doesnt work. I have a random music player that chooses a random song from a table, plays it, and I need it to wait the ranndom music's time length, I have it set right. But TimeLenth doesnt work because its a roblox bug. So is there any other way to do this? |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2015 01:21 PM |
| Stop doing it from the server. |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2015 01:22 PM |
| Try printing out the TimeLength and see if it comes out with the right value. |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 01:22 PM |
Heres my script
while true do wait(1) local music = {script.RazorSharp,script.Disconnected,script.RainbowRoad,script.HighRoller,script.Idols,script.PinkKoeks,script.EnergyDrink,script.EvilGameboy,script.MakoBeam,script.Surface} for i,v in pairs(game.Players:GetChildren()) do local randommusic = (music[math.random(#music)]) print(randommusic) randommusic:Play() print(randommusic.TimeLength) wait(1) wait(randommusic.TimeLength) print(randommusic.TimeLength) end end
It prints the TimeLength the first time but not printing the second time. |
|
|
| Report Abuse |
|
|
Netakra
|
  |
| Joined: 02 Dec 2015 |
| Total Posts: 606 |
|
|
| 19 Dec 2015 01:26 PM |
| Just use one sound and have a table of song IDs that you will use. Make sure you have the part that is like http://roblox.asset=? or something like that before the ID when you play it. |
|
|
| Report Abuse |
|
|
| |
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 01:27 PM |
So I just make 1 sound and make a table of ID's and do like
http://roblox.asset=randommusic
or wotever it is |
|
|
| Report Abuse |
|
|
|
| 19 Dec 2015 01:40 PM |
local ids = {283801001, 149281165, 274727125, 313694441} --List of song ID's. local playing = false
while wait(1) do if playing == false then local song = ids[math.random(1, #ids)] local sound = Instance.new("Sound", game.Workspace) sound.Name = "Song" sound.SoundId = ("rbxassetid://"..song) sound:Play() playing = true wait(.1) wait(sound.TimeLength) playing = false sound:remove() end end |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 04:47 PM |
Plays all the songs at once again.
Still not waiting the TimeLength |
|
|
| Report Abuse |
|
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 19 Dec 2015 04:49 PM |
| TimeLength is broken. Use the Ended event: http://wiki.roblox.com/index.php?title=API:Class/Sound/Ended |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 04:55 PM |
How would you make it wait until it calls Ended?
wait(sound.Ended) doesnt work
Sorry, never used it qq |
|
|
| Report Abuse |
|
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 19 Dec 2015 04:59 PM |
It's an event, you'd use it like:
sound.Ended:connect(function()
end)
or
function soundEnded()
end
sound.Ended:connect(soundEnded) |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 19 Dec 2015 05:06 PM |
It only plays 1 song then doesnt go on?
local ids = {168159428, 198403839, 147584090, 291054681, 145763936, 179667611, 144935194, 161993332, 165065112, 300766271} --List of song ID's. local playing = false
while wait(1) do if playing == false then local song = ids[math.random(1, #ids)] local sound = Instance.new("Sound", game.Workspace) sound.Name = "Song" sound.Volume = 0.5 sound.SoundId = ("rbxassetid://"..song) sound:Play() playing = true wait(.1) function soundEnded() wait(soundEnded) playing = false sound:remove() end end end
game.Workspace.Song.Ended:connect(soundEnded) |
|
|
| Report Abuse |
|
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 19 Dec 2015 05:19 PM |
This should work:
local ids = {168159428, 198403839, 147584090, 291054681, 145763936, 179667611, 144935194, 161993332, 165065112, 300766271};
local playing = false;
while wait(0) do
if not playing then
local song = ids[math.random(1,#ids)];
local sound = Instance.new("Sound", workspace);
sound.Name = "Song"; sound.Volume = 0.5; sound.SoundId = "rbxassetid://"..song;
sound:Play(); playing = true;
sound.Ended:connect(function()
playing = false; sound:Destroy();
end)
repeat wait(0) until not playing
end
end |
|
|
| Report Abuse |
|
|
Metology
|
  |
| Joined: 06 Oct 2014 |
| Total Posts: 3255 |
|
| |
|
|
| 19 Dec 2015 06:34 PM |
while true do wait() -- Lets the computer know that it can take it's time. script.Sound:Play() - You can change the name for Sound :D wait(1) script.Sound2play() - You can change the name for Sound2 :P wait(1)
end
Add sound. Put in the ID, and it will work!
Do you have any questions? Just contact Poppopcole by PMing him! Merry Christmas! |
|
|
| Report Abuse |
|
|
Aethex
|
  |
| Joined: 16 Oct 2011 |
| Total Posts: 2193 |
|
|
| 19 Dec 2015 06:59 PM |
| @poppopcole not only is that inefficient, it would play every song forever while increasing at 1 second intervals, they never stop, and it wouldn't work in the first place since the second sound has a syntax error |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
|
| 20 Dec 2015 11:37 AM |
| @Aethex Your script only plays 1 song and nothing after it. |
|
|
| Report Abuse |
|
|
|
| 20 Dec 2015 11:38 AM |
| Is a .Value missing anywhere? |
|
|
| Report Abuse |
|
|
sal212
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 2929 |
|
| |
|
nox7
|
  |
| Joined: 29 Aug 2008 |
| Total Posts: 27467 |
|
|
| 20 Dec 2015 11:42 AM |
"TimeLength is broken."
Wrong. The reason his stuff isn't working is because the first reply to this thread was the ONLY CORRECT ANSWER.
None of the sound properties (newer ones) work from the server and need to be one in a LocalScript. |
|
|
| Report Abuse |
|
|
| |
|