Perfect sync animations

I see that there are dance maps in Roblox where players activate specific dance animations and other players can synchronize, the animations are perfectly aligned for all players present on the map.

I’m doing something very similar, but only the player who synchronized can see the correctly synchronized animation, other players see the animations out of sync.

I believe that there is just some detail to fix this problem, could someone explain it to me? Thanks! o/

I’ve worked on something similar before, you need to play the animation and simply implement a system that checks every few seconds or so if a Player’s animation.TimePosition is different to the Player they’re sycing with’s animation.TimePosition

The code should look something like this

while true do
local TimeElapsed = task.wait(.1)

local SelfTimePosition = AnimationTrack.TimePosition
local TargetTimePosition = TargetAnimationTrack.TimePosition

local Difference = math.abs(SelfTimePosition - TargetTimePosition)

if Difference >= TimeElapsed then
SelfTimePosition.TimePosition = TargetTimePosition
end
end