I have a replication system in my game where every client plays every animation and effect for themselves (I know it’s redundant for animations but it did not cause issues earlier) and an animation doesn’t seem to stop on the server side for a reason I don’t quite understand.
I have a looped barrage animation and first I tried just using :Stop
on it and it works perfectly, but the animation ends abruptly and I wanted to make it smoother, so I tried setting .Looped
to false to stop it but it did not work (doesn’t stop on server) so I added a delayed :Stop
and it still does not work. I am out of ideas and I can’t seem to find a similiar post with a solution that works on the dev forum.
Here’s the code and result for my first solution (note I’m using the for loop because just calling :Stop()
on the AnimationTrack
object caused the server to not replicate animation stopping as well in previous attacks):
for index, animation in ipairs(animator:GetPlayingAnimationTracks()) do
if animation.Animation.Name == "PunchFlurry" then
animation.Looped = false
animation:Stop()
end
end
Result: https://streamable.com/dg6xa7
Second version:
for index, animation in ipairs(animator:GetPlayingAnimationTracks()) do
if animation.Animation.Name == "PunchFlurry" then
animation.Looped = false
-- math.max in case for whatever reason animation.Length returns 0.
task.delay(math.max(animation.Length - animation.TimePosition, 0.01), function()
animation:Stop()
end)
end
end
Result: https://streamable.com/2fn2rn
I’m guessing taht the client thinks the animation is over, so :Stop()
doesn’t do anything and the server for whatever reason doesn’t stop the animation once the client does (I think it might have to do with me setting .Looped
to false). Is there any way to stop server from replicatiing animations to other clients?