Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to get TimeLength in test/play mode ? [UnSolved]

Studio 4.896 2.168 4.896

Test0 0 0

 wait(10)
music = script:GetChildren()
a = true
while a == true do
wait(1)
a = false
for i,v in pairs(music) do
local MusicRandom = music[math.random(1,#music)]
MusicRandom:Play()
if music[i].IsPlaying then
	print(music[i].TimeLength)
wait(music[i].TimeLength)
a = true
end
end
end

1 answer

✓ Accepted answer
 wait(10)
music = script:GetChildren()
while wait(1) do
local MusicRandom = music[math.random(1,#music)]
MusicRandom:Play()
if MusicRandom.IsPlaying then --use MusicRandom instead of music[i] because music[i] isnt the randomly selected music piece.
print(MusicRandom.TimeLength)
wait(MusicRandom.TimeLength)
end
end --the variable 'a' seemed useless in this problem so I toke it out if you don't mind

Try that.

4 comments

0

still 0

0

You sure the audio has an audio id in it?

0

yes

0

Also having a problem with TimeLength returning 0 even when playing..

This discussion is preserved as it was. New answers, comments, and votes are closed.