So i have a leaderboard in my race game and players can see the meters of top 5 player in the race. The meters are checked in server so i need to send the data from server to clients to update leaderboard ui (the meters are changing in almost every frame if players are moving). What is the most efficient way to handle this? I heard about unreliable remote events but im not so sure how they work. Any ideas?
instead of unnecessary network being sent, you could just check the meter on the client and do your logic on the client as long as the meter is predictable
Just use NumberValue.
Just put a value in replicated storage and update it on the server. On the client update their UI once on join/character loads and then every time the value changes(using events). Basically when you update an instance that is parented in replicated storage on the server, it will also update its copy for all the clients, even the ones that join after said update.
This does work, you just have to keep in mind that any time you change NumberValue.Value, you’re replicating the new value to all clients. So, if your goal is to reduce the amount of data replicating every frame, the you’d want these NumberValue objects to be used exclusively for transmitting the data, not also the only source of truth for the values. This way, you can manually throttle the updates by doing something like writing the meter values to the NumberValue objects only 2 times per second (roughly every 6 frames) instead of every frame. Replicating any data like this at full 60fps is pretty pointless, and it’s generally better to send fewer samples and just do some smoothing (interpolation) on the client side.
RemoteEvents are, overall, probably the most efficient and tunable way to send your data. You can manually track which values have changed since the last-sent update, and just send new values. This makes the receiving client code cleaner too, since you have just one event.OnClientEvent to bind to, not a bunch of ValueObject.Changed listeners all contributing function call overhead.
If you do use remote events, and optimize them to send only changes, you do have to remember to have newly-connecting clients get sent all the values at join time, to initialize their displays to the current state, so things don’t pop on as they get updated or stay showing placeholder values.