Another method you could use is to get the current TimePosition of the animTrack, then Stop it and when you want to start it up again, replay the same animTrack but set the TimePosition back to the last position before it was stopped.
Or maybe you can try to set the AdjustSpeed to (0.0) or (0.01)… the problem don’t seem to come from your script so there is no other solution to it unfortunatly.
Oh wait, i noticed that you created a new track in your function, and it have the exact same name as your main track, maybe it come from there so the script is confused between the main track and the new track
I’ve removed the section where the script creates a new track before, and the problem was still there. Also, could you show a code example of what you meant from the first reply?
Also another solution would be to do a completely different animation…
like instead of pausing the current animation at a keyframe, you can made another animation in which the character is static and have the wanted pause… and inside the script instead of pausing the track you stop it and run a new one with the static animation in a looped mode.
(Reply to your code example) Ok, I kind of get it. But I don’t want to continue the animation from a certain point the next time I fire it, I just want to freeze it for a bit then stop it.
local animTrack = hum:LoadAnimation(MovingAnimation)
animTrack:Play()
animTrack:GetMarkerReachedSignal("Parry"):Connect(function()
animTrack:Stop()
local pausedAnimTrack = hum:LoadAnimation(PausedAnimation)
pausedAnimTrack.Looped = true
pausedAnimTrack:Play()
hbLoop = hb:Connect(function(deltaTime)
if ... then
--print(parryTimer[char])
else
pausedAnimTrack:Stop()
end
if ... then
local newAnimTrack = hum:LoadAnimation(anim)
newAnimTrack:Play()
newAnimTrack:AdjustSpeed(parryAnimSpeed)
end
end)
end)
I’ve just done something pretty similar to what you have above, but the problem is that there’s still a delay when “animTrack:Stop()” gets called. This results in the previous animation still running for a bit past the marker event before the new animation is played.
Can you add a new marker a bit before the Parry one to prevent this delay ?
Like if the delay is approximately 0.1s, add a new marker 0.1s before the Parry
Hmm okay, i have a lack of solution now, sorry
If the delay randomly happen no matter which method you use, i don’t know if you can really do something about it, especially if it come from Roblox backend and its natural client/server replication delay.
local animTrack = char.Character.Animator:LoadAnimation(anim)
But it still has the same delay.
A solution that I found was just adding the same frame of animation directly after the marker in the animation editor, so that even if there’s a delay, the animation would stop at the same position. It doesn’t work out 100% of the time and it makes the whole animation a bit lengthier, but it’s way better than before.
You could just extend this same frame time by a whole sec to keep the character in pause and prevent any delay time.
And in case you want to resume it, you can set the track TimePosition at the right keyframe when the character movements resume.