if player == LocalPlayer then
That is why. You should only check if a player is the local player for UI-related functions. Just use the player you are passed in the callback.
Another way to think of it is like this: everything except the UI is synchronized in multiplayer. So, anything that affects ONLY the local player will not be synchronized and cause sync errors to happen.
Also, cool to see someone using my API. Hopefully it has been useful.