What is the best method for sending data from the player to the client?
I know of two methods: defining the data as an attribute in the player and sending the data in an event (as a buffer) to the client.
Attributes are amazing, I definitely recommend using them if you want the client to recognize any data coming from the server.
Moreover, if you’re using the roblox leaderstats, it shouldn’t be a problem to just grab it from there as well.
While RemoteEvents are also functional, they require every client script in use of that data, to store it in a variable of their own, rather than a client-server shared method like attributes.
I using ProfileService and the BridgeNet2 to Events
It depends what data you’re sending, whether the data is static (unchanging), and whether the data is private.
Here are my recommendations:
- If it’s private, use RemoteEvents or ReplicaService. If it’s not private, attributes are an option.
- If it’s static, use whatever is easiest. If it’s changing, use ReplicaService or attributes.
- If it’s complex (e.g. multi-layer tables), ReplicaService or RemoteEvents are probably simpler.
There are some exceptions to this though:
- Complex data could be replicated using string attributes and JSON encoded data. (This would probably need to be one way though, and would be very inefficient for changing data compared to ReplicaService, which only replicates changes.)
- Private data could be replicated using attributes stored inside PlayerGui, since PlayerGui selectively replicates to only its respective client.
- RemoteEvents could replicate dynamic data (which is what ReplicaService uses internally), however it’s complicated to make this efficient (e.g. only replicating changes) and reliable, so might as well not reinvent the wheel.
Also, ReplicaService is just one solution for the problem it fills, and I imagine there are alternatives (though it’s made by loleris so it’s probably the best :p).
do u mean to send it from 1 player to another? or from the server to the player
no, server to client, when server change something in the data he send to the player the change, by attribute or remove event