I’m working on a game and in this game I’ve decided to decrease load times by populating the map with props retrieved from replicated storage on the client side. This allows me to only replicate the prop once, ever, and I can use all that saved time to make the prop much higher quality.
This, however, is a bit of a double-edged sword when it comes to mobile. The memory limit prevents me from displaying any prop that could be considered high quality, so naturally your first though is to display low-quality props instead. That, however, will not accomplish anything because the mobile client will still have the high-quality props replicated to it because there is no way to replicate something to only one client.
My solution is these API additions:
[code]NetworkServer
Method :ReplicateToClient(Player client, String title, Instance object)
Method :GetReplicatedObject(Player client, String title) → Instance object
Event .ClientReplicated(Player client, String title, Instance object)
NetworkClient
Method :ReplicateToServer(String title, Instance object)
Method :GetReplicatedObject(String title) → Instance object
Event .ServerReplicated(String title, Instance object)[/code]
client is the target client.
title is a string that tells the code on the other machine how to handle the object
object is the object
ReplicateToServer/Client is used to send the object to the other machine, it fires the Client/ServerReplicated event when received, and the object can then be retrieved in the future using GetReplicatedObject on the machine it was sent to.
GetReplicatedObject returns the object that was replicated using that title
Server/ClientReplicated is fired when an object is received
When an object is replicated it will only be replicated once, when you call the method. If you call the method again on the same object then the object will update, and if you use a different title the event will fire.
EDIT: Probably better solution: