Issue with sound

I’m creating a sound and every time I try to get it’s length, it’s zero despite the song being a minute and a half long.

function sound(id)
	local s= workspace:FindFirstChild("Music") or Instance.new("Sound", workspace)
	s.Name = "Music"
	s.Volume = 2
	s.SoundId = string.format("rbxassetid://%d", id)

	sound:Play()

	return sound
end

local s = sound(142376088)

print(s.TimeLength) --> 0

It could possibly be in part due to not being loaded in yet. Perhaps wait until it is loaded in before you get its length.

repeat wait() until s.IsLoaded

print(s.TimeLength)
1 Like