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: wait(song.TimeLength)

Previous Thread :: Next Thread 
sal212 is not online. 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
CailThePuppy is not online. CailThePuppy
Joined: 11 Dec 2015
Total Posts: 91
19 Dec 2015 01:21 PM
Stop doing it from the server.
Report Abuse
sonicboy01 is not online. sonicboy01
Joined: 22 Nov 2008
Total Posts: 923
19 Dec 2015 01:22 PM
Try printing out the TimeLength and see if it comes out with the right value.
Report Abuse
sal212 is not online. 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 is not online. 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
sonicboy01 is not online. sonicboy01
Joined: 22 Nov 2008
Total Posts: 923
19 Dec 2015 01:27 PM
Work's for a single song.
Report Abuse
sal212 is not online. 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
sonicboy01 is not online. sonicboy01
Joined: 22 Nov 2008
Total Posts: 923
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. Metology
Joined: 06 Oct 2014
Total Posts: 3255
19 Dec 2015 05:38 PM
wait(120)
Report Abuse
poppopcole is not online. poppopcole
Joined: 16 Dec 2011
Total Posts: 276
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 is not online. 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 is not online. 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
ElectoStriking is not online. ElectoStriking
Joined: 10 May 2014
Total Posts: 1547
20 Dec 2015 11:38 AM
Is a .Value missing anywhere?
Report Abuse
sal212 is not online. sal212
Joined: 11 Apr 2010
Total Posts: 2929
20 Dec 2015 11:39 AM
Im not using values
Report Abuse
nox7 is not online. 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
CailThePuppy is not online. CailThePuppy
Joined: 11 Dec 2015
Total Posts: 91
21 Dec 2015 04:45 AM
dog 3 human 0
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