-
What do you want to achieve? Keep it simple and clear!
New API to replicate server-made instances to specific client(s). -
What is the issue? Include screenshots / videos if possible!
There is currently no ideal way as a Roblox developer to replicate server made instances to specific clients. -
What solutions have you tried so far?
The only “solution” to this is having the instances be descendants of the Player’s PlayerGui which obviously is not what PlayerGui is intended for.
You can create an instance on the server, then pass it through a RemoteEvent:FireClient() call which takes a player and any other arguments provided.
That player can then parent the passed instance locally.
Using PlayerGui as a storage container doesn’t make much sense to me.
Why not run a chain of events resembling something like this:
- Player Joins
- Folder added to ReplicatedStorage w/ Players Name
- Local script deletes this folder for all clients outside of the player who joined
You can then parent these “Server Made Instances” to the clients you want without them replicating to all clients. The folder wouldn’t exist on the client therefore the item would not exist on the client either - at least in theory that is.
My bad, didn’t make this clear. The server would be able to see the instance and edit it etc as usual.
But only specific clients can see that instance?
This is possible through remote events/functions since you can fire individual clients. It’s really only a matter of making an api wrapper for this. On the client you would want to probably handle 3 main things: index, newindex, and namecall (roblox methods), and you could pretty much get instance parody.
Yes, only the specific clients would be able to see these instances.
The server would not be able to interact with the instance if it was made on the client.
A popular technique in real world situations is that the server only provides information about the object. The clients are responsible for calculating and positioning/modifying their version of the instance locally.
You could have the server control a non-collidable, invisible instance. All the clients would then replicate the server’s movements on their screen.
It’s not easy, but it’s do-able with RemoteEvents.
I actually did this before; my method was to assign unique IDs to every instance created (and index the instance with those IDs in a dictionary on the client) so the server could interact with specific instances.
That’s what I am currently doing, but I am afraid exploiters can just delete that script etc.
How does this make it so other clients are unable to see these instances?
Only the clients you want to see the instance will create and modify it.
The instances are created on the client so they are not replicated to other clients. Server has knowledge of these instances through ID. (This is currently how I handle replication for stuff like effects as well)