There’s an outstanding bug with ROBLOX animations: if a client joins after an animation is played, it won’t be playing when they join the game. An idea to solve this that pops into mind is keeping track of playing animations on the server and their time, and replicating this to new clients so they can locally play the animation. There are problems with this though. One, playing an animation replicates even with filtering enabled, so if you tried to locally play it on top of the same animation, they’ll fight each other. Two, the fighting will look significantly worse the more inaccurate your tracked TimePosition is (due to latency).
So how do we solve the issue? By eliminating the case that animations have played before a client joins. How is this possible? We can’t bend time, but we can restart animations from the owner clients whenever someone joins a game. If you hook into PlayerAdded, and stop/play all animations starting at their current TimePosition, technically all animations have now started after all clients have joined the game, and will play correctly on the new client. Since you’re stopping/starting from the same place instantly, there is no hiccup in the animations either.
So onto the code. Insert the following code into a localscript into StarterCharacterScripts. It’s standalone, so it won’t need to interface with any of your scripts, and you won’t need to modify your scripts. The only side effect is that this may fire some animationtrack related events, so if you find your animations triggering stuff whenever players join, you may need to adjust your scripts:
game.Players.PlayerAdded:connect(function()
local humanoid = script.Parent.Humanoid
local animations = humanoid:GetPlayingAnimationTracks()
for _,track in next,animations do
local originalPosition = track.TimePosition
track:Stop(0)
track.TimePosition = 0
track:Play(0)
track.TimePosition = originalPosition
end
end)
Edit: Updated code to have a fadeTime of 0 so there wasn’t any delay with playing/stopping the animation.
It’d still be nice if ROBLOX fixed this, so there was never a need to patch it ourselves in the first place, but until then, the fix isn’t so bad.