As a Roblox developer, it is currently hard to replicate objects from the server to an individual client.
Problem: Developers want to explicitly replicate a game object to a single client. Placing the object into ReplicatedStorage will replicate to all clients, not an individual. Developers are currently forced to use hacky solutions, such as placing game objects in the player’s PlayerGui.
(This works because the PlayerGui doesn’t replicate to other players, but it is clearly not a preferred method)
Solution: Provide a service or API to replicate an object to specific clients.
Here’s a possible solution I could think of using ReplicatedStorage:
- Add the method:
void ReplicatedStorage:Replicate(Instance object, Player client)
- Add the event for client:
- The object will then be parented under ReplicatedStorage only for the given player.
-- Server: local part = Instance.new("Part") game.ReplicatedStorage:Replicate(part, game.Players.SomePlayer)
-- Client: game.ReplicatedStorage.OnReplicated:Connect(function(part) print(part:GetFullName()) -- > ReplicatedStorage.Part end)
Obviously there are strange scenarios to consider: What does the server do with the object? Does it parent it somewhere? What if it gets destroyed server-side? What if the object gets parented into the game and thus replicated to everyone?
Ideally in my mind, the client should make a copy of the object and thus is no longer linked to the server-side object that it came from. Therefore, any server-side changes to the object won’t affect the client-side object.