when cloning a sound instance, for some reason the TimeLength property is ignored. is this a bug or am i doing something wrong?
task.wait()
local sound = script.Parent.test
local clone = sound:Clone()
print("original TimeLength: " .. sound.TimeLength)
print("original Volume: " .. sound.Volume)
print("original Name: " .. sound.Name)
task.wait(2)
print(" ")
print("clone TimeLength: " .. clone.TimeLength)
print("clone Volume: " .. clone.Volume)
print("clone Name: " .. clone.Name)
output:
original TimeLength: 95.451
original Volume: 5
original Name: test
clone TimeLength: 0
clone Volume: 5
clone Name: test
This is probably printing 0 because the cloned sound is not fully loaded yet. The time length is displayed as 0 until the sound is fully loaded.
Edit: Although, the wait time should be able to have it loaded by then, unless the loading is very slow.
Try checking the sound when it is fully loaded by using Sound.IsLoaded/Sound.Loaded.
i guess timelength just takes an eternity to load, i tried changing the wait time to 10 and it still prints 0
i did find a weird workaround though: reparenting the clone and waiting for the next heartbeat
task.wait()
local sound = script.Parent.test
local clone = sound:Clone()
clone.Parent = workspace
task.wait()
print(clone.TimeLength)
95.451 - Server - Script:9
not sure if this is consistent though
Actually, the sound might not load until parented, since clone automatically parents the object to nil.
Good way to parent the sound:
local clone = sound:Clone().Parent = sound.Parent
I chose to parent it into the same location the other sound it so it will be together
oh well, that works lol
task.wait()
local sound = script.Parent.test
local clone = sound:Clone()
clone.Loaded:Connect(function()
print("loaded")
print(clone.TimeLength)
end)
task.wait(5)
print("reparented")
clone.Parent = workspace
reparented - Server - Script:14
loaded - Server - Script:8
95.451 - Server - Script:10