How to change animation duration to sound length

Hello! I was making a script which changes animation’s duration to sound’s length. Like animation and sound should end at the same time. Here is the script I wrote:

local sound = game.Workspace.Sound
local anim = game.Workspace.Dummy.Animation
local hum = game.Workspace.Dummy.Humanoid
local animationTrack = hum:LoadAnimation(anim)

animationTrack:AdjustSpeed(animationTrack.Length/sound.TimeLength)

wait(0.1)

sound:Play()

animationTrack:Play()

Animation still isn’t synched with sound and I’m very confused since I don’t know what to do with it. I’m not sure if I did it right, because I could not check the correctness through the output, also visibly it still doesn’t work. What do I do to fix it?

1 Like

Does it work if you call AdjustSpeed after calling Play?

Can you show a video of the animation and the sound to show it not synced up?

Are you setting this on the server or on the client? If on the server you will have network delay and they may play out of sync.