How should I handle tweens (Server vs client)?

I’m working on a project and need some advice on how to handle tweens, specifically for when a player opens or closes a door, cabinet, fridge, etc.

Currently, I have it set up so that when a player interacts with a door, a tween fires and opens the door. However, I’m not sure whether the tween animation should be triggered on the server or the client. I want to make sure that all players in the server see the door animation at the same time. I’m going to be creating A LOT of interactable objects that trigger tweens when clicked, so I want to make sure that everything is efficient.

Any help or guidance would be appreciated. Thanks.

2 Likes

You’ll want to handle the animations on the client to reduce networking load, plus the animations will be smoother since client framerate is higher than networking replication frequency.

The server should just keep track of the state of the objects and inform clients of changes so they can handle it themselves. This also allows you to skip animations on objects that can’t be seen for added performance gains.

If latency is a concern, you can send timestamps from the server via workspace:GetServerTimeNow() and then compare the result on the client, reducing the duration of the animation or something to compensate for the latency, but unless the action is gameplay-critical, it probably isn’t worth the complexity to implement. Animations being off by a few tenths of seconds are usually fine, and everything else is off by that amount of time, too.

1 Like

Personally I have server scripts playing tweens of objects as I want them to replicate to all clients without any extra steps. Dont know if its the best practice thought