If I want to replicate some ROBLOX objects from the server to individual clients (i.e. not replicate to all clients), the only way to do that is parent the objects to a non-replicating container that’s visible to the server. Off the top of my head, the only one is PlayerGui, and this is really hacky. If you want to go from client -> server, it’s impossible. We can sort of work around this by serializing objects into strings and then sending those across the network, but unions/meshparts can’t be serialized.
This is not ideal. We should have a proper way to replicate ROBLOX objects between the server and individual clients.
The general game will mostly rely on prefabs that are already supplied in the client and loaded up per server request. If that is impossible, serialization seems pretty clean to me.
I’m curious what you’re trying to do here?
I can only guess two options: loading assets or trying to secure your maps / weapons.
Loading assets. Having everything downloaded on the client as soon as they join means slow join times since they all have to be downloaded and loaded into memory – this is a problem with mobile devices that likely have both a bad connection and hardware. Any method of inserting that replicates to other clients is no good because then everyone has to re-download the content. Inserting through InsertService, whether it be through the server or client, isn’t an option because items inserted through InsertService automatically replicate to all clients. Serialization isn’t an option because it doesn’t work with unions or MeshParts.
Woud be nice to have
All instances passed on will be replicated (if they aren’t for that player already).
On the receiving end, we can always parent it to where we want it to be.
(FireAllClientsWithReplicated maybe too then)
I’d imagine it as sort of container (like ReplicatedStorage). Where you’d have models in there, and could call :ReplicateToPlayer(player, model) and that model would pop up in the container on their end. The client could destroy it at will.
I do something like this in my rpg, since we have hundreds of swords (read: hundreds of meshes/unions) I keep all models in serverstorage. This way clients only download them when they’re in use by someone (server inserts it into workspace). But this is a “replicate to all” solution, not a specific solution.
I wonder if you can do this for each client:
- Server creates a folder in the client’s PlayerGui
- Server waits until the client sends a signal that it can see the folder
- Server parents the folder to ServerStorage (or another non-replicating storage)
- Client parents the folder to its ServerStorage (idem ^)
Now the server has a folder for each client in ServerStorage.
Each client can only see its own folder.
I wouldn’t mind testing this in studio (and even online), but my pc isn’t very… working right now…
You can just parent the objects directly to the PlayerGui to individually replicate them. The server can see the PlayerGui object – changes to the PlayerGui just don’t replicate to anyone. That being said, this is a hacky workaround, and why the feature request was initially proposed.